登录表单无效

时间:2010-07-19 16:01:49

标签: php

它给出了错误的结果。我使用Dreamweaver,我刚开始学习PHP,我觉得很难调试。

</html>
<head>
<title>Login Form</title>
</head>

<body>
<fieldset><legend>Login</legend>
<form action="login.php" method="post" /><br/>
Username<input type="text" name="User" /><br/>
Password<input type="password" name="Pass" /><br/>
<input type="submit" value="submit" />
<input type="reset" value="clear"/>
</form>
</body>
</html>





<?php
$_user=$_POST["user"];
$_pass=$_POST["pass"];
if(($user=="hamza")&&($pass=="2"))
echo "Access Granted";
else echo "access denied";
?>

1 个答案:

答案 0 :(得分:3)

if(($user=="hamza")&&($pass=="2"))

应该是

if($_user=="hamza" && $_pass=="2")

$_user=$_POST["user"];
$_pass=$_POST["pass"];

应该是:

$_user=$_POST["User"];
$_pass=$_POST["Pass"];

案件很重要!

能够一目了然地看到这些错误:在本地启用display_errors(不在实时服务器上),并在php.ini中将error_reporting设置为E_ALL。这会让你注意到$ user&amp; $ pass变量不存在。