我有一个登录系统,用户必须登录才能访问主网站。但是,验证不起作用。
主要是password
功能不正常。任何建议为什么?
<?php
session_start();
$login = mysql_real_escape_string($_POST['login']);
$password = mysql_real_escape_string($_POST['password']);
if ($login&&$password)
{
$connect = mysql_connect("localhost", "root", "") or die("Couldn't connect");
mysql_select_db("a&e") or die("Couldn't find db");
$query = mysql_query("SELECT * FROM users WHERE login='$login'");
$numrows = mysql_num_rows($query);
if ($numrows==!0)
{
//code to login
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['login'];
$dbpassword = $row['password'];
}
//check to see if they match
if($login==$dbusername&&$password==$password)
{
$_SESSION['login']=$username;
$_SESSION['password']=$password;
sleep(5);
header('Location: nindex.php');
die();
}
else
die ("incorrect password");
}
else
die("That user does not exist");
}
else
die("please provide a username and password");
?>