我需要您对此登录脚本的帮助。当用户注册时,active
数据库中的一列设置为零 (0),并且激活链接将发送到他们提供的电子邮件。单击激活链接时,如果成功,则它们各自的active
列设置为 1。
但是只有当我单击提交按钮两次时,用户名和密码的正确组合才有效。
在第一次单击时,我得到以下几行
注意:未定义的索引:请记住第 37 行的 C:\wamp\www\church\login.php
尚未验证
但是当我第二次单击登录时。
<?php
if (isset($_POST['submit'])) {
$username = trim($_POST['username']);
$username = strip_tags($_POST['username']);
$username = htmlentities($_POST['username']);
$username = stripslashes($_POST['username']);
$username = mysql_real_escape_string($_POST['username']);
$password = sha1($_POST['password']);
if (isset($_POST['username']) && isset($_POST['password'])) {
$query = mysql_query("SELECT username, password
FROM USERS
WHERE username = '$username'
AND password = '$password'") or die (mysql_error());
$user = mysql_num_rows($query);
if ($user == 1) {
$row = mysql_fetch_assoc($query);
if ($row['active'] == 1) {
$_SESSION['logged_username'] = $username;
if ($_POST['remember']) {
setcookie("CookieUser", $_SESSION['logged_username'], time() + 60 * 60 * 24 * 100, "/");
setcookie("CookiePass", $password, time() + 60 * 60 * 24 * 100, "/");
header('Location: http://127.0.0.1/church/index.php?id=1');
}
}
if ($row['active'] !== 1) {
echo "Not Verified Yet";
}
}
else {
echo "<div id='content' >";
echo "<div class='OpenError' >";
echo "Username & Password Combination Is Wrong";
echo "</div>";
echo "</div>";
}
}
}
?>