我创建了登录会话,它显示了一个错误:未识别myusername
并且mypassword
在这些行中。我不明白为什么。
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
这是我的 checklogin.php
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>
这是我的登录表格:
<form action='checklogin.php' method="post" >
Username
<input name='myusername' type="text">
Password
<input name='mypassword' type="password">
<input type="submit" name="Submit" value="Login">
</form>