这是因为我来自丹麦并使用谷歌翻译,因为我对英语不好,所以希望它能与之保持一致,但是,这就是我的MySQLI代码直到最后的话,以及说有错误。我曾尝试用正确的密码和电子邮件写入,但它不能以某种方式工作,它会一直犯错误,它怎么可能?
<?php
session_start();
include("include/database/db.php");
if($stmt = $mysqli->prepare("SELECT id, djnavn, hemmelig, rank FROM `brugere` WHERE `email` = ? AND `password` = ?"))
{
$stmt->bind_param('ss', $email, $password);
$email = $_POST['email'];
$password = sha1($_POST['password']);
$stmt->execute();
$stmt->bind_result($id, $djnavn, $hemmelig, $rank);
$stmt->fetch();
$count_res = $stmt->num_rows;
$stmt->close();
if($count_res > 0) {
$_SESSION["logged_in"] = true;
$_SESSION["user_id"] = $id;
$_SESSION["djnavn"] = $djnavn;
$_SESSION["hemmelig"] = $hemmelig;
$_SESSION["rank"] = $rank;
if($rank == 0)
{
echo "Your can not log in!";
}
if($rank == 1)
{
echo "Ok, members you can log in now!";
}
if($rank == 2)
{
echo "Ok, Admin you can log in now!";
}
}
else {
echo 'fail her: ' . $mysqli->error;
}
}
?>
你可以帮帮我!!
答案 0 :(得分:0)
首先是它的通知,因为您在使用之前没有定义$ email和$ password。
$email = $_POST['email'];
$password = sha1($_POST['password']);
剪切并粘贴它们,因为你绑定参数:
$stmt->bind_param('ss', $email, $password);