我创建其链接到数据库的登录,输入信息时登录然后运行一个空白页,什么也不做,下面是我的代码:PHP登录问题
include "conn.php";
session_start();
$email_address = $_POST['email_address'];
$password = $_POST['password'];
if ($email_address && $password)
{
$connect = mysql_connect("computing","i7906890","password") or die ("couldn't connect!");
mysql_select_db("i7906890") or die ("couldn't find database");
$guery = mysql_query("SELECT * FROM UserAccount WHERE email_address = '$email_address'");
if ($numrows!=0) {
//code to login
while ($row = mysql_fetch_assoc($query)) //Password Check
{
$dbemail_address = $row['email_address']
$dbpassword = $row['password']
}
//Check if they match
if ($email_address==$dbemail_address&&$password==$dbpassword)
{
echo "You're in! <a href='user_page.php'>click</a> here to enter the members page";
$_SESSION['user']==$dbemail_address;
}
else
echo "Incorrect Password!";
}
else
die("That user doesn't exist!");
}
else
die("Please enter an email address and password!");
?>
而且,这里是我的形式
<form action = "login2.php" method ="POST">
<p><img src="images/space.gif" width="70px" height="1px"/><strong>Log in</strong> or <a href="register_form.php"><strong>Register</strong></a><br>
Email:<img src="images/space.gif" width="34px" height="1px"/><input type="text" name="user" size="33"> <br>
Password:<img src="images/space.gif" width="10px" height="1px"/><input type="password" name="password" size="33"> <br>
<div align="center">
<input type="submit" value="Log in" class="button">
</div>
</p>
</form>
请帮忙! SOS
什么是最小代码工作?你必须看看哪里出了问题,诊断究竟是什么原因,然后研究修复/避免这种情况。那么,如果你失败了,你可以问一个问题,“不工作”不是一个问题。 – 2013-03-14 13:38:45
'请帮忙! SOS'是的,你的意思很深......但并不符合你的期望......即使你的代码运行良好,你也是第5或第6位,他们大致提出了同样的问题,充满了[SQL注入](http://en.wikipedia.org/wiki/SQL_injection)在PHP登录表单中使用已弃用的** mysql _ **函数... – ppeterka 2013-03-14 13:39:27
做一些调试。 '回声“在这里达到等等等等;'在每个块和条件之后检查执行哪个路径。你也可以输出变量,所以你会知道究竟是什么被发送到页面,从数据库中获取什么,等等...... – 2013-03-14 13:42:18