<html>
<head>
<title>Gmail validation</title>
</head>
<body bgcolor="pink">
<form method="post" action="">
<div class="container">``
<span>User Name:</span>
<input type="text" name="uname" placeholder="Enter your email" size="23" required>
<span>Password:</span>
<input type="password" name="upass" placeholder="Enter your password" size="23" required>
<input type="submit" value="Sign in" name="submit">
<input type="button" value="Sign up" onclick="myFucntion()">
</div>
</form>
<?php
if (isset($_POST['submit'])) {
print_r($_POST);
$username = $_POST['uname'];
$password = $_POST['upass'];
if ($username && $password) {
$con = mysqli_connect("localhost", "root", "");
mysqli_select_db($con, "sms");
$rows = mysqli_num_rows($result);
$result = mysqli_query($con, "SELECT * FROM student1 WHERE username = '$username' ");
if ($rows == 1) {
while ($data = mysqli_fetch_assoc($result)) {
$dbusername = $data['username'];
$dbpassword = $data['password'];
}
if ($username == $dbusername && $password == $dbpassword) {
echo "Yes you are loged in";
//header("Location: ");
}
else
{
echo "Enter correct password";
}
}
else
{
echo "Enter correct username";
}
}
else
{
echo "Enter both username and password";
}
}
?>
</body>
</html>
我通过在php中检查数据库验证用户名和密码。
我收到以下错误
警告:mysqli_num_rows()要求参数1为mysqli_result,boolean 给出。
注意:我的数据库名称:sms
Table name: student1
如何解决这个问题。