我正在學習如何使用「的setcookie」,但是,我不能讓下面的行工作, 我在這裏貼上我的所有代碼,如果有人能夠給請我幫忙? 不知道原因。 非常感謝。PHP的模具()不工作(簡單的代碼)
else{ die ("hahahahahahahahahahahahahaha"); }
HTML代碼
<form method="POST" action="">
<div class="error"><?php echo $error;?></div>
<p></p>
<label>Username: </label><br>
<input type="text" name="username"><br>
<label>Password: </label><br>
<input type="password" name="password"><br>
<input type="checkbox" name="rememberme"> Remember me<br>
<input type="submit" name="submit" value="Login">
PHP代碼
<?
if(isset($_POST['submit'])){
//get data
$username = $_POST['username'];
$password = $_POST['password'];
$rememberme = isset($_POST['rememberme']);
echo $rememberme;
if($username&&$password){
$login = mysql_query("SELECT * FROM form WHERE username='$username'");
while ($row = mysql_fetch_assoc($login))
{
$db_password = $row['password'];
if (md5($password)== $db_password)
{
$logstatus = TRUE;
}
else{
$logstatus = FALSE;
}
if ($logstatus == TRUE)
{
if ($rememberme == "1")
setcookie("username", $username, time()+600);
else if ($rememberme == "")
$_SESSION['username'] = $username;
echo " I am here";
}
else{
die ("hahahahahahahahahahahahahaha"); //unable to get here
}
}
}
else{
echo "enter username/password";
}
}
?>
你不需要爲1分貝行 – 2012-08-09 03:48:16
一個while()循環您能得到什麼? – xdazz 2012-08-09 03:49:21
是否將$ logstatus設置爲FALSE?即密碼是否與傳入的密碼相匹配?如果die()沒有被調用,你會看到:echo「我在這裏」; ? – Roger 2012-08-09 03:50:06