各位高手大家好,最近小弟用PHP做一个图书管理系统的毕业设计,但是由于出错,不知是什么原因,还望高手能够帮忙解答,小弟不胜感激,代码如下:
config.php
<?
global $hostname,$dbuser,$dbname,$dbpassword,$book_table,$send_table,$user_table;
$hostname="localhost";
$dbname="book";
$dbuser="root";
$dbpassword="root";
$db=mysql_connect($hostname,$dbuser,$dbpassword) or die("数据库连接错误!");
mysql_select_db($dbname,$db);
$book_table="book_list";
$send_table="book_lend";
$user_table="book_user";
?>
<?php
//用户身份验证
include "config.php";
$query=mysql_query("select * from $book_user where user_name='$user' and user_pass='$password'");
$num=mysql_num_rows($query); //出错的地方代码if ($num == 0)
{
include "header.php";
echo "请你确认用户名和密码是否正确?<br><br>";
echo "<a href=index.php>重新填写</a><br><br>";
}
else
{
setcookie("cookie_pass", "$password", time()+10000, "/");
setcookie("cookie_user","$user",time()+10000,"/");
include "header.php";
echo $user ;
echo "你好恭喜你!<br><br>";
echo("<HTML><META http-equiv=\"refresh\" content =\"0;url=book_list.php\"></HTML>");}
include "foot.php";
?>
config.php
<?
global $hostname,$dbuser,$dbname,$dbpassword,$book_table,$send_table,$user_table;
$hostname="localhost";
$dbname="book";
$dbuser="root";
$dbpassword="root";
$db=mysql_connect($hostname,$dbuser,$dbpassword) or die("数据库连接错误!");
mysql_select_db($dbname,$db);
$book_table="book_list";
$send_table="book_lend";
$user_table="book_user";
?>
<?php
//用户身份验证
include "config.php";
$query=mysql_query("select * from $book_user where user_name='$user' and user_pass='$password'");
$num=mysql_num_rows($query); //出错的地方代码if ($num == 0)
{
include "header.php";
echo "请你确认用户名和密码是否正确?<br><br>";
echo "<a href=index.php>重新填写</a><br><br>";
}
else
{
setcookie("cookie_pass", "$password", time()+10000, "/");
setcookie("cookie_user","$user",time()+10000,"/");
include "header.php";
echo $user ;
echo "你好恭喜你!<br><br>";
echo("<HTML><META http-equiv=\"refresh\" content =\"0;url=book_list.php\"></HTML>");}
include "foot.php";
?>
$send_table="book_lend";
$user_table="book_user";
这是你的3个表,看得比较明白
可是你这个select * from $book_user where user_name='$user' and user_pass='$password'
里的$book_user是那个表呢?写错了大哥