我有一個代碼,詢問數據庫中是否存在一行,如果它存在,它會回顯一條消息。但是,沒有不管我把什麼輸入迴盪PHP如果聲明mysqli_num_rows不起作用
這裏是我的代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$mysqlhost="host";
$mysqldatabase="b33_15887129_Accounts";
$mysqlusername="username";
$mysqlpassword="password";
$connect=new mysqli($mysqlhost,$mysqlusername,$mysqlpassword);
if (!$connect) {
die("Connection failed: " . $connect->connect_error);
}
echo "Connected Successfully";
mysqli_select_db($connect,"b33_15887129_Accounts");
$loginusername=$_POST['loginusername'];
$loginpassword=$_POST['loginpassword'];
$checkifexist="SELECT * FROM Users WHERE Username='$loginusername' AND 'Password=$loginpassword'";
$runquery=mysqli_query($connect,$checkifexist);
$numofrows=mysqli_num_rows($runquery);
if($numofrows==1){
echo "Successfully logged in!";
}else{
echo "Failed to log in";
}
?>
</body>
</html>
它管理呼應Connected successfully
但Successfully logged in
和Failed to log in
沒有出現無論什麼輸入。任何幫助?
''Password = $ loginpassword''。這應該是正確的,'密碼='$ loginpassword'' – Ranjith 2015-03-02 09:21:16
在數據庫上的明文密碼恐怖的尖叫,驚恐地注入$ _POST值直接到SQL語句 – 2015-03-02 09:27:25