即使使用不正確的用戶名和密碼登錄,請幫助我找出問題出在哪裏。我希望它只能登錄,只有當它匹配用戶名和密碼,但它完全是錯誤的。使用錯誤的用戶名和密碼登錄
下面的代碼:
<form name="login" method="post" action="countries.php">
<p> </p>
<table border=0 width=500px align=center>
<tr>
<td>Enter User Name</td>
</tr>
<tr>
<td><input type=text size=30 value="" name=t1></td>
</tr>
<tr>
<td>Enter Password</td>
</tr>
<tr>
<td><input type=password size=30 value="" name=t2>
</td>
</tr>
<tr>
<td><input type=reset value="Clear Form" name=b2>
</td>
<td><input type=submit value="Login Form" name=b4>
</td>
</td></tr>
<tr>
<td><input type=submit value="Guest User" name=b5>
</td>
</tr>
</table>
<hr />
</center>
<?php
$t1="Maha";
$t2="abc";
if($t1 == "Maha" && $t2 == "abc")
{
header("countries.php");
exit;
echo " We are glad you are visiting us again. Lets plan yout tour together." ;
}
else {
header("final.php");
exit;
echo " User name or password is incorrect. Try again.";
}
?>
</form>
**旁註:**您錯過了'header'函數的'location'關鍵字。 –
你正在定義你的值 - >'$ t1 =「Maha」; $ t2 =「abc」;'所以他們永遠是正確的。更改爲'$ t1 = $ _ POST ['t1']; $ t2 = $ _ POST ['t2'];',除了'header(「Location:final.php」)中缺少'location'' – Sean