我查看了許多網站比較各種登錄腳本並找不到任何解決方案。我把正確的信息,並得到一個'無效登錄',如果我不把任何東西在那裏我得到一個'無效登錄'。我真的可以使用一些幫助來排除故障。下面是代碼嘗試使用php和mysql登錄時收到「無效登錄」
<?php
include_once ('dbc.php');
$user_email = mysql_real_escape_string(isset($_POST['email']));
if (isset($_POST['Submit'])=='Login')
{
$md5pass = md5($_POST['pwd']);
$sql = "SELECT id,user_email FROM users WHERE
user_email = '$user_email' AND
user_pwd = '$md5pass' AND user_activated='1'";
$result = mysql_query($sql) or die (mysql_error());
$num = mysql_num_rows($result);
if ($num = 0)
{
// A matching row was found - the user is authenticated.
session_start();
list($user_id,$user_email) = mysql_fetch_row($result);
// this sets variables in the session
$_SESSION['user']= $user_email;
if (isset($_GET['ret']) && !empty($_GET['ret']))
{
header("Location: $_GET[ret]");
} else {
header("Location: myaccount.php");
}
//echo "Logged in...";
exit();
}
header("Location: login.php?msg=Invalid Login");
//echo "Error:";
exit;
}
?>
表單代碼----
<td bgcolor="#e5ecf9" class="mnubody"><form name="form1" method="post" action="">
<p> </p>
<p align="center">Your Email:
<input name="email" type="text" id="email">
</p>
<p align="center"> Password:
<input name="pwd" type="password" id="pwd">
</p>
<p align="center">
<input type="submit" name="Submit" value="Login">
</p>
<p align="center"><a href="register.php">Register</a> | <a href="forgot.php">Forgot</a></p>
</form></td>
這是一個建議:簡化代碼直到它工作,然後逐個添加功能。 – 2012-01-12 02:18:04
請發佈表格代碼 – 2012-01-12 02:19:44
我看到你正在做某種類型的電子郵件激活。你確定該部分正在工作,並將值設置爲1? – 2012-01-12 02:21:18