-1

这是因为我来自丹麦并使用谷歌翻译,因为我的英语不好,所以希望它可以与它保持一致,但是,这就是我的 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; 
            }
        }
?>

你能帮我吗!!

4

1 回答 1

0

首先是通知,它发生是因为您在使用 $email 和 $password 之前没有定义它们。

$email = $_POST['email'];
$password = sha1($_POST['password']);

在绑定参数之前剪切并粘贴它们:

$stmt->bind_param('ss', $email, $password);
于 2012-05-07T13:49:39.860 回答