我在这里跟随一个教程系列:https ://www.youtube.com/watch?feature=player_embedded&v=bribF8a3fgo我正在使用下面的代码,是的,我知道有更好的方法来做到这一点。虽然我收到此错误:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/friends/login.php on line 26
我不知道为什么,我很确定我输入的所有内容都是正确的,但我不确定。介意看看吗?谢谢。
<html>
<head>
<title>Login - Friend System</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php include 'connect.php'; ?>
<?php include 'functions.php'; ?>
<?php include 'header.php'; ?>
<div class="container">
<h3>Login</h3>
<form method="post">
<?php
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) or empty($password)) {
$message = "Fields Empty, Please Recheck";
}else {
$check_login = mysql_query("SELECT id FROM users WHERE username='$username' AND password='" . md5($password) . "'");
if(mysql_num_rows($check_login) == 1) {
$message = "Ok!";
} else {
$message = "Username and/or password incorrect!";
}
}
echo "<div class='box'>" . $message . "</div>";
}
?>
Username: <br/>
<input type="text" name="username" autocomplete="off"/>
<br/><br/>
Password: <br/>
<input type="password" name="password" />
<br/><br/>
<input type="submit" name="submit" value="Register">
</form>
</div>
</body>
</html>
第 26 行是:
if(mysql_num_rows($check_login) == 1) {