1
我希望我的用戶能夠使用他們的帳戶登錄,所以我創建了一個html表單和一個php文件,將與mySQL數據庫進行通信。 php代碼應該檢查用戶名和密碼是否正確並存在於數據庫中。如果是這樣,用戶被授予訪問權限。我想這樣的算法:PHP&MySQL登錄表單錯誤與訪問數據庫表
<?php
//connection_start
$mysqli = new mysqli('mysql3.000webhost.com','a4305565_os','******','a4305565_users');
//check_connection
if($mysqli->connect_error){
die("Connection error (check_connection): " . $mysqli->connect_errno . " : " . $mysqli->connect_error);
exit();
}
//check_if_account_exists
$query = mysql_query("SELECT * FROM `users` where `username` = '$_POST[form_username]' AND `password` = '$_POST[form_password]'") or die(mysql_error());
$row = mysql_fetch_array($query) or die(mysql_error());
//verification
if(!empty($row['username']) AND !empty($row['password'])){
echo "SUCCESSFULLY SIGNED IN.";
}else{
die("Your are not registered yet.");
}
//Connection_end
$mysqli->close();
?>
但是,當我在我的虛擬主機上測試代碼,它給我的錯誤就行14說,我
沒有對數據庫的訪問「 a4305565_users「與密碼= NO
或類似的東西。
請幫忙嗎?