我創建其鏈接到數據庫的登錄,輸入信息時登錄然後運行一個空白頁,什麼也不做,下面是我的代碼: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