我查看了许多网站比较各种登录脚本并找不到任何解决方案。我把正确的信息,并得到一个'无效登录',如果我不把任何东西在那里我得到一个'无效登录'。我真的可以使用一些帮助来排除故障。下面是代码尝试使用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