首 页   · 站长博客 · 用户注册 · 会员登陆  · 会员排行  ·最新主题  ·最近回复  精华区  版权声明  ·论坛管理
  当前登录身份:游客,请先登录。  笔名: 口令: 验证码:   
楼 主  index »  PHP安装/语法/函数 » 【求助】PHP网页代码问题,求高手帮助。  


  作者:51552448
  注册时间:2008-06-13
  主题/回复:1/0
  积分:31
  等级:★(二级)
  称号:初出茅庐

用户联系方式已设置为保密

 

 发表:2008-06-13 16:34:19 阅读 3116 次 回复 1 次 得分1  |   字号 字色
【求助】PHP网页代码问题,求高手帮助。
请高手帮我看下这个代码:
代码如下:<?
//初始化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>



但我是新手,实在不清楚错在哪。麻烦高手了。
 
 1#楼  
 
  回复人:coolboy0316
  注册时间:2008-03-11
  主题/回复:19/44
  积分:367
  等级:★★(四级)
  称号:崭露头角

   
 1#楼 发表于2008-09-18 07:52:26  评分:1 

回复给楼主(51552448)
你有什么错误?
把主要代码写上来?
搞这么多代码,谁有时间看啊?
  页数1/1首页 « 1 » 末页
  发表回复:您还没有登陆,无法发表回复。请先[登陆]

一起PHP技术联盟 主办:一起PHP 联系方式:站长QQ:4304410 QQ群:8423742 20159565 站长博客 E-mail: nqp@nqp.me 执行时间:0.025sec
SimsmaBBS 2008 (v6.0) Developed by 17php.com,Copyright(C)2003-2010 All rights reserved. 副本授权:一起PHP官方专用版