我一直在嘗試在PHP中創建登錄系統。 我已經設法成功地連接到數據庫,但我有一個問題說嘗試創建登錄系統時出錯
警告:mysql_num_rows()預計參數1是資源,布爾在C中給出:\ xampp1 \ htdocs中\登錄\檢查.PHP在線23
錯誤的用戶名或密碼是錯誤的 公告:未定義的屬性:mysqli的:: $關閉在C:\ xampp1 \ htdocs中\登錄\ check.php上線36
我的代碼是:
<html>
<head>
<title>Login Page</title>
</head>
<body>
<form method="post" action="check.php" >
<table>
<tr>
<td><label>Username</label></td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td><label>password</label></td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td><input type="submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
ob_start();
$username= $_POST['username'];
$password= $_POST['password'];
$servername= "localhost";
$username= "root";
$password = "";
$dbname="login";
$conn= mysqli_connect($servername,$username,$password,$dbname);
if (!$conn){
die("Not connected". mysqli_connect_error);
}else{
echo "connection sucessful";
}
$sql= "select * from details where $username=username and $password=password";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if ($count == 1){
header("location:sucess.php");
}else{
echo "Wrong username or password are wrong";
}
$conn->close;
ob_end_flush();
在代碼中混合使用'mysqli和mysql' – Saty
再次查看該查詢 – 2016-02-27 13:20:11
username ='$ username'是您正在查找的內容,請閱讀PDO –