如何做登出的功能(附上已做好登入的程式碼)

edited 八月 2014 in PHP新手區
<form name="login" action="login.php" method="post" onSubmit="return check();">

  <p><FONT SIZE=5><FONT FACE="標楷體">帳號:</FONT></FONT>
    <input type="text" name="account" maxlength="15">
    <br />
   </p>
  <p><FONT SIZE=5><FONT FACE="標楷體">密碼:</FONT></FONT><input type="password" name="passwd" maxlength="10"><br />
    </p>
  <p>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;<input type="submit" value="登入">&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     <input type="reset" name="button" id="button" value="清除">
  </p>
  <p>&nbsp;</p>

</form>
</CENTER>
<script language="javascript">

function check() {

if (document.login.account.value==''){

alert('您忘了輸入帳號');

document.login.account.focus();

return false;

}

if (document.login.passwd.value==''){

alert('您忘了輸入密碼');

document.login.passwd.focus();

return false;

}

return true;

}

</script>


上面式登入的畫面

下面這個 是抓取資料庫資料
<meta http-equiv="Content-Type" content="text/html; charset=Big5" />
<?

mysql_pconnect("localhost","root","qclab") or die("無法連接主機");

mysql_select_db("wu") or die ("無法連接資料庫");



$sql="SELECT * FROM user where username='$account' and passwd='$passwd'";

$chk=mysql_query($sql);

$final=mysql_fetch_row($chk);

if($final!=NULL){

 echo '<meta http-equiv=REFRESH CONTENT=1;url=function_page.php>';
}else{

echo "對不起,您的帳號或密碼有誤!<br />";

}

?>
想問如何登出呢?
標籤:

評論

Sign In or Register to comment.