<?php
session_start();
?>
<!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>Member System - Login</title>
</head>
<body>
<?php
$form = "<form action='login.php' method='post'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user' /</td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /</td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login' /</td>
</tr>
</table>
</form>";
if ($_POST['loginbtn']){
$user = $_POST['user'];
$password = $_POST['password'];
if ($user){
if ($password){
require("connect.php");
$password = md5(md5("sjkdhfgh".$password."asdfhh"));
// make sure login info correct
$query = mysql_query("SELECT * FROM users WHERE username='$user'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
die(mysql_error());
$row = mysql_fetch_essoc($query);
$dbid = $row ['id'];
$dbuser = $row ['username'];
$dbpass = $row ['password'];
$dbactive = $row ['active'];
if ($password == $dbpass){
if ($dbactive == 1){
// set seccion info
$_SESSION['userid'] = $dbid;
$_SESSION['username'] = $dbuser;
echo "You Have Been Logged In As <b>$dbuser</b>. <a
href='index.html'>Click Here</a> To Go Home";
}
else
echo "You Must Activate You Accout To Login. $form";
}
else
echo "You Did Not Enter The Right Password. $form";
}
else
echo "The Username You Entered Was Not Found. $form";
mysql_close();
}
else
echo "You Must Enter Your Password. $form";
}
else
echo "You Must Enter Your UserName. $form";
}
else
echo $form;
?>
<body>
</html>
我正在尝试创建一个登录网页,但我不断收到此错误
连接到 MySQL
警告:mysql_num_rows() 期望参数 1 是资源,布尔值在 D:\Hosting\11742398\html\Test\Login.php 第 41 行给出的用户名未找到。