我想在PHP中創建一個登錄表單。我傳遞用戶輸入的用戶名和密碼,並檢查數據庫中存在的天氣。Mysql查詢IFEXIST不返回任何結果
我已經完成了編碼,但IF EXIST查詢不返回任何結果。
任何人都可以幫助我解決這個問題。或給我一個替代的想法..謝謝...
<?php
$name= $_POST["usname"];
$pass = $_POST ["password"];
$connection = mysqli_connect("localhost","sathya","sathya","learning1");
//mysqli_query($connection,"INSERT INTO user (name, password) VALUES ('".$name."', '".$pass."')");
$result = mysqli_query($connection, "IF EXISTS(SELECT * FROM user WHERE name='".$name."'AND password='".$pass."')");
mysqli_close($connection);
echo "result ".$result;
if($result == True){
header("Location: logedin.php");
//redirect_to('logedin.php');
}else{
echo "not logged in installed";
}
?>
你閉上你的連接。 – user3517652
我試圖不關閉連接,它不起作用。 –
「IF EXISTS」沒有,只有'SELECT IF ...' –