这段代码有什么问题?
if(isset($_REQUEST["ok"])) {
$id= mysql_real_escape_string($_REQUEST["usr"]);
$pwd=mysql_real_escape_string($_REQUEST["pass"]);
$row=mysql_query("select * from tbl_login where usr_id='$id' and password='$pwd'");
$data=mysql_fetch_array($row);
if($pwd==$data["password"]) {
$usr=mysql_query("select * from tbl_usr where u_id='".$data['u_id']."'");
$nm=mysql_fetch_array($usr);
$_SESSION["usr"]=$nm["u_fname"];
$_SESSION["id"]=$nm["u_id"];
header("location:index.php");
} else {
$msg="Email Or Password not valid";
}
}
HTML代码是
<form method="post" enctype="multipart/form-data" >
Email-Id<input type="text" name="usr" />
<br/>
Password<input type="password" name="pass"/>
<input type="submit" value="Login" name="ok" />
</form>
当用户在未填写用户名和密码的情况下单击提交按钮时,页面应重定向到索引页面。