我一直在尝试在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 –