<form action='login.php' method='POST'>
Username: <input type='text' name='Username'><BR>
Password: <input type='password' name='Password'><BR>
<input type="checkbox" name="remember" > Rember Me
<input type='submit' value='Log in'>
<a href="reg.php"> Register </a>
<?php
session_start();
include 'db.php';
$Username = $_POST['Username'];
$Password = $_POST['Password'];
if ($Username&&$Password)
{
$query = mysql_query("SELECT * From Users WHERE Username='$Username'");
$numrow = mysql_num_rows($query);
if ($numrow!=0)
{
while ($row = mysql_fetch_assoc($query))
{
$Username = $row['Username'];
$Password = $row['Password'];
}
// check to see if they match
if ($Username==$Username&&$Password==$Password)
{
echo "You're in. <a href='index.php'>Click</a> here to enter the member page";
$_SESSION['Username']=$Username;
}
else
echo "Incorrect password";
}
else
die("That user doesn't exist");
}
else
die ("please enter a username and a password");
?>
我得到的错误是:
注意: 未定义索引:第48行/home/stud/0/1314683/public_html/MathsrUs/login.php中的用户名注意:未定义索引:第49行/home/stud/0/1314683/public_html/MathsrUs/login.php中的密码
答案 0 :(得分:0)
$ _POST
中没有数据$Username = $_POST['Username'];
$Password = $_POST['Password'];
检查是否通过POST访问页面,您可以检查是否使用 $ _ SERVER [&#39; REQUEST_METHOD&#39;] 变量。