好的,这是我第一次在这个网站上提问,但是我走了。所以即时通讯学习如何创建登录等。我正在观看一个视频,他做了一行代码,由于某种原因,我做了同样的事情而且没有用。如果有人能提供帮助那就太棒了。
代码:
<?php
if ($_POST['loginbtn']){
$user = $_POST['user'];
$password = $_POST['password'];
if($user){
if($password){
require("../testing/dbconfig.php");
//encrypt password
$password = md5(md5("a4v".$password."weed"));
//verify user is real
$query = mysql_query("SELECT * FROM user WHERE username='$user'");
$numrows = mysql_num_rows($query);
if($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$dbuser = $row['username'];
$dbpass = $row['password'];
$dbactive = $row['active'];
if ($password == $dbpass){
if($dbactive == 1){
//allowing users session
$_SESSION['userid'] = $dbid;
$_SESSION['username'] = $dbuser;
echo "Logged in as <b>$dbuser</b>. Please wait while you are redirected.";
}
else
echo "This account has not been activated. Please contact admin if you think this is a problem.";
}
else
echo "The password that was entered was invalid. Please check spelling.";
}
else
echo "Username was not valid. Please check spelling and try again";
mysql_close();
}
else
echo "<center style='font-size:32px; color:red;'>You must have a set Password/center>";
}
else
echo "<center style='font-size:32px; color:red;'>You must have a set Username</center>";
}
else
echo "<center style='font-size:32px; color:red;'>Waiting for login requests....</center>";
&GT;
现在错误就是在这里拍摄
$numrows = mysql_num_rows($query);
if($numrows == 1){
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$dbuser = $row['username'];
$dbpass = $row['password'];
$dbactive = $row['active'];
收到结束时出错
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /srv/disk10/1954442/www/satan.cf/testing/login.php on line 56 Username was not valid. Please check spelling and try again