请高手帮我看下这个代码:代码如下:<?
//初始化session
session_start();
include ('head.php');
require ('dbconnect.php');
// 如果没有登录,退出
if(!isset($_SESSION['Adm'])) {
echo "<p align=center>";
echo "<font color=#FF0000 size=5><strong><big>";
echo "管理员没有登录,请<a href='AdminLogin.php'>登录</a>!";
echo "</big></strong></font></p>";
exit();
}
?>
<html>
<body>
<?
// 提交前
if ($show1=="" and $show2=="" and $lend==""){
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF ?>">
<table width="60%" border="0" cellspacing="1" cellpadding="3" align="center">
<tr>
<th colspan="2">信 息 登 记</th>
</tr>
<tr>
<td width="30%" height="32" align="right">图书编号:</td>
<td width="70%" height="32">
<input type="text" name="book_id" size="10">
<input type="submit" name="show1" value="显示该书信息">
</td>
</tr>
<tr>
<td width="30%" height="32" align="right">用户ID:</td>
<td width="70%" height="32">
<input type="text" name="user_id" size="10">
<input type="submit" name="show2" value="显示该用户信息">
</td>
</tr>
</table>
</form>
<?
}
// 提交后处理
else {
// 只是显示图书详细信息
if ($show1){
// 如果图书编号没填写,提示用户
if ($book_id==""){
echo "<div align=center><font color=red>图书编号没有填写!</font></div>";
exit();
}
else {
$booksql="select * from book where id='$book_id'";
$bookresult=mysql_query($booksql,$conn);
$bookinfo=mysql_fetch_array($bookresult);
// 编号有误,没有这本书
if (empty($bookinfo)){
echo "<div align=center><font color=red>不存在该图书编号</font></div>";
exit();
}
else {
// 如果该书已经全部借出,提示用户
if ($bookinfo[leave_number]=="0"){
echo "<div align=center><font color=red>该图书已全部借出!</font></div>";
}
// 显示该书详细信息
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF ?>">
<table width="60%" border="0" cellspacing="1" cellpadding="3" align="center">
<tr>
<th colspan="2">借 书 登 记</th>
</tr>
<tr>
<td width="30%" height="32" align="right">图书编号:</td>
<td width="70%" height="32"><?echo $book_id?>
<? // 传递图书ID信息 ?>
<input type="hidden" name="book_id" value="<? echo $bookinfo[id];?>">
<input type="hidden" name="title" value="<? echo $bookinfo[title];?>">
<input type="hidden" name="leave" value="<? echo $bookinfo[leave_number];?>">
</td>
</tr>
<tr>
<td width="30%" align="right">书名:</td>
<td width="70%"><? echo $bookinfo[title];?></td>
</tr>
<tr>
<td width="30%" align="right">作者:</td>
<td width="70%"><? echo $bookinfo[author];?></td>
</tr>
<tr>
<td width="30%" align="right">出版社:</td>
<td width="70%"><? echo $bookinfo[publisher];?></td>
</tr>
<tr>
<td width="30%" align="right">出版年份:</td>
<td width="70%"><? echo $bookinfo[publish_year];?></td>
</tr>
<tr>
<td height="23" align="right">总共:<? echo $bookinfo[total];?>本;</td>
<td height="23">库存剩余:<? echo $bookinfo[leave_number];?>本</td>
</tr>
<tr>
<td width="30%" align="right">借阅用户ID:</td>
<td width="70%">
<input type="text" name="user_id" size="10">
</td>
</tr>
<tr>
<td width="30%" align="right">
<input type="submit" name="lend" value="借出">
</td>
<td width="70%">
<input type="reset" name="Submit2" value="重置">
</td>
</tr>
</table>
</form>
<?
}
// 提交后处理
else {
if ($show2){
// 如果用户编号没填写,提示用户
if ($user_id==""){
echo "<div align=center><font color=red>用户编号没有填写!</font></div>";
exit();
}
else {
$usersql="select * from user where id='$user_id'";
$userresult=mysql_query($usersql,$conn);
$userinfo=mysql_fetch_array($userresult);
// 编号有误,没有此用户
if (empty($userinfo)){
echo "<div align=center><font color=red>不存在该用户编号</font></div>";
exit();
}
// 显示用户详细信息
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF ?>">
<table width="60%" border="0" cellspacing="1" cellpadding="3" align="center">
<tr>
<th colspan="2">用 户 信 息</th>
</tr>
<tr>
<td width="30%" height="32" align="right">用户ID:</td>
<td width="70%" height="32"><? echo $user_id;?>
</td>
</tr>
<tr>
<td width="30%" align="right">用户名:</td>
<td width="70%"><? echo $userinfo[name];?></td>
</tr>
<tr>
<td width="30%" align="right">密码:</td>
<td width="70%"><? echo $userinfo[password];?></td>
</tr>
<tr>
<td width="30%" align="right">邮箱:</td>
<td width="70%"><? echo $userinfo[email];?></td>
</tr>
<tr>
<td width="30%" align="right">电话:</td>
<td width="70%"><? echo $userinfo[tel];?></td>
</tr>
<tr>
<td width="30%" align="right">地址:</td>
<td width="70%"><? echo $userinfo[address];?></td>
</tr>
</table>
</form>
问题应该出在
代码如下:<?
}
// 提交后处理
else {
if ($show2){
// 如果用户编号没填写,提示用户
if ($user_id==""){
echo "<div align=center><font color=red>用户编号没有填写!</font></div>";
exit();
}
else {
$usersql="select * from user where id='$user_id'";
$userresult=mysql_query($usersql,$conn);
$userinfo=mysql_fetch_array($userresult);
// 编号有误,没有此用户
if (empty($userinfo)){
echo "<div align=center><font color=red>不存在该用户编号</font></div>";
exit();
}
// 显示用户详细信息
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF ?>">
<table width="60%" border="0" cellspacing="1" cellpadding="3" align="center">
<tr>
<th colspan="2">用 户 信 息</th>
</tr>
<tr>
<td width="30%" height="32" align="right">用户ID:</td>
<td width="70%" height="32"><? echo $user_id;?>
</td>
</tr>
<tr>
<td width="30%" align="right">用户名:</td>
<td width="70%"><? echo $userinfo[name];?></td>
</tr>
<tr>
<td width="30%" align="right">密码:</td>
<td width="70%"><? echo $userinfo[password];?></td>
</tr>
<tr>
<td width="30%" align="right">邮箱:</td>
<td width="70%"><? echo $userinfo[email];?></td>
</tr>
<tr>
<td width="30%" align="right">电话:</td>
<td width="70%"><? echo $userinfo[tel];?></td>
</tr>
<tr>
<td width="30%" align="right">地址:</td>
<td width="70%"><? echo $userinfo[address];?></td>
</tr>
</table>
</form>
但我是新手,实在不清楚错在哪。麻烦高手了。 |