我知道这已经被问了很多,但我似乎无法为我找到正确的答案。在 PHPMyAdmin 中,用户名“user”和密码“test”存在——但由于某种原因,它一直说不存在。代码的输出是:
成功连接到数据库邮箱:*user* 密码:*test* 用户名和密码不匹配
这是代码:
$con = new mysqli('somewhere.com','admin','*****','nameofdb');
if($con->connect_errno > 0){
die('Unable to connect to database [' . $con->connect_error . ']');
}
else{
echo "Successfully connected to DB ";
}
$email = mysqli_real_escape_string($con, $_POST['eml']);
$password = mysqli_real_escape_string($con, $_POST['pwd']);
//$encrPassword = md5($password);
$login = $con->query("SELECT *
FROM logininfo
WHERE email = $email
AND password = $password");
if($login == FALSE){
echo " email:*$email* ";
echo " password:*$password* ";
//echo " password:*$encrPassword* ";
echo "Username and Password does not Match";
}
else {
echo "Hey this works";
//Check if user is logged in, if not then redirect.
/*session_start();
if($_SESSION['loggedin'] == FALSE){
$_SESSION['loggedin'] = TRUE;
$_SESSION['username'] = $username;
}*/
header("Location: ../browse/index.php");
}
mysqli_close($con);