PHP登录系统

时间:2016-01-23 15:07:53

标签: php mysql web login

我创建了带有示例记录的MySQL数据库用户: user:administrator,password:one1Samba(md5哈希)

当我尝试连接时会遇到很多错误: 这是我的代码:

if(isset($_POST['login']))
{
include_once("db.php");
$username = strip_tags($_POST['username']);
$upassword = strip_tags($_POST['password']);

$username = stripslashes($username);
$password = stripslashes($password);

$username = mysql_real_escape_string($_POST['username']);;
$password = mysql_real_escape_string($_POST['password']);;

$password = md5($password);

$sql = "SELECT * FROM users WHERE username = '$username' LIMIT 1 ";
$query = mysqli_query($db,$sq1);
$row = mysqli_fetch_array($query);
$id = $row['id'];

$db_password = $row['password'];

if($password ==$db_password)
{
$SESSION['username'] = $username;
header("Location : index.php"); 
}
else
{
echo "YOu didn't enter the correct details!";
}

}

错误:

警告:mysqli_query()要求参数1为mysqli,在第21行的C:\ xampp \ htdocs \ One1 \ login.php中给出null

警告:mysqli_fetch_array()要求参数1为mysqli_result,在第22行的C:\ xampp \ htdocs \ One1 \ login.php中给出null 你没有输入正确的细节!

0 个答案:

没有答案