PHP我的选择不起作用?

时间:2015-08-21 15:15:51

标签: php mysql

我相信我的PHP能够完美运行,因此我认为这是一个查询错误。当我继续,在会话中存储表单详细信息...它很高兴地返回我的发布信息,但似乎没有从我的数据库中提取任何内容 - 我的数据库中有一行包含我正在使用的电子邮件地址。有没有人看到这个PHP公然出错?

感谢您的帮助。

<?php
session_start();
$servername = "localhost";
$username = "privatedbroot";
$password = "not4ulol";
$dbname = "pdb_inventory";
$status = $_GET["action"];
$_SESSION["Cemail"] = $_POST["CEMAIL"];
$_SESSION["Access"] = md5($_POST["ACCESS"]);
$conn = new mysqli($servername, $username, $password, $dbname);


    $sql = "SELECT CEMAIL, ACCESS FROM POPU WHERE `CEMAIL`= ".$_SESSION['Cemail'];
    echo $sql;
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            if ($_SESSION["Access"] == $row["ACCESS"]){
                echo "password correct!";
            } else {
                echo "password wrong!";
            }
        }
    }else{
        echo "ur email is wrong m8.";
    }
?>

1 个答案:

答案 0 :(得分:0)

试试这个:

$cemail = $_SESSION['Cemail'];
$sql = "SELECT CEMAIL, ACCESS FROM POPU WHERE `CEMAIL`= '$cemail'";