登錄我可以通過簡單地圍繞它包裝加密我用MD5密碼 -不能與加密口令從數據庫
$Password = md5($_POST['password']);
加密的密碼被存儲在數據庫中成功當用戶註冊。但是,當我想用純文本密碼登錄時,它決定不了。我該如何解決這個問題?
<?php
if(isset($_POST['btnlogin'])) {
$Email = $_POST['email'];
$Password = $_POST['password'];
$Email = mysqli_real_escape_string($connection, $Email);
$Password = mysqli_real_escape_string($connection, $Password);
$query ="SELECT * FROM customers WHERE Email = '{$Email}' AND Password = '{$Password}'";
$select_customer_query = mysqli_query($connection, $query);
if (!$select_customer_query)
die("QUERY FAILED". mysqli_error($connection));
}
while($row = mysqli_fetch_array($select_customer_query)) {
$Email_db = $row['Email'];
$Password_db = $row['Password'];
$Firstname_db = $row['First_Name'];
$Lastname_db = $row['Last_Name'];
$string ="logged in as";
$logoutlink = '/ <a href="includes/back/logout.php">Logout</a>';
}
if ($Email_db == $Email || $Password_db == $Password ) {
header("Location: ../../index.php");
$_SESSION['FirstName'] = $Firstname_db;
$_SESSION['LastName'] = $Lastname_db;
$_SESSION['string'] = $string;
$_SESSION['logoutlink'] = $logoutlink;
}
?>
你不在將密碼傳遞給SQL查詢進行比較之前再次輸入密碼... –
以及如何我做這個? – steve
更改$ Password = mysqli_real_escape_string($ connection,$ Password);到$ Password = md5($ Password); –