我知道這已被問了很多,但我似乎無法爲我找到正確的答案。在PHPMyAdmin中,用戶名「user」和密碼「test」存在 - 但由於某種原因,它一直說它沒有。代碼的輸出是:MySQL/PHP的:無法從數據庫中選擇,但元素存在
成功連接到數據庫的電子郵件:*用戶*密碼:*測試*的用戶名和密碼不匹配
這裏是代碼:
$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);
解密它的標誌我是用MD5加密,但隨後它拿出來幫助調試處理。每當我回應我得到的查詢:DB SELECT * FROM用戶WHERE電子郵件=測試和密碼=測試 – user2597843
與db中的密碼長度不應該太短,在註冊和登錄都刪除加密然後嘗試。 –
我刪除了所有加密。沒有運氣。 :| – user2597843