| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1271 人关注过本帖
标题:留言板无法正确发布
只看楼主 加入收藏
shenyulv
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:166
专家分:150
注 册:2009-3-8
结帖率:96.43%
收藏
已结贴  问题点数:0 回复次数:3 
留言板无法正确发布

留言板的源码中有三个文件 message_list.php ,message_process.php , message_post.php,分别是显示留言的列表,留言的处理,和留言发布的文件。连接数据库是没错的。但是我在 message_post.php发布的留言,在message_list.php 显示不出来,是怎么回事啊?新手,帮帮忙、、吧

message_list.php

<?php
//嵌入两个数据库文件
include("db_conn.php");
include("db_func.php");
//取出留言数据并按发布时间递减排序SQL语句
$SQLsrt="SELECT*FROM message ORDER BY m_time DESC";
$res=db_query($SQLsrt);//执行SQL语句命令
?>

<table width="750" border="0" align="center" cellpadding="0" cellspacing="1">
<tr bgcolor="#00FF33">
<td width="290" align="center">
<font color="#009900">留言主题</font>
</td>
<td width="300" align="center">
<font color="#FF0033">留言内容</font>
</td>
<td width="60">
<font color="#0000FF">留言人</font>
</td>
<td width="100">
<font color="#333333">留言时间</font>
</td>
</tr>
<?php
if (db_num_rows($res)>0)//表中有数据
{
$row=db_fetch_array($res);//取得数据条数
$check=$p+10;//每页去10条

//显示留言板列表的字段内容
for($i=0;$i<$num;$i++)//显示多条留言数据
{
$row=db_fetch_array($res);
//选取第$p条道$check条数据
if($i>=$p&&$i<$check)
{
if($i%2==0) //利用是否被整除来判断字段的背景颜色
echo "<tr bgcolor='#DDDDDD'>";
else
echo"<tr>";
if(strlen($row['m_title'])>15)//判断字段字符串是否超过15个字节
{
echo"<td width='280'><a href='message_show.php? m_id=".$row['m_id']."'>";
echo substr($row['m_title'],0,30)."...</a></td>";
}
else
{
echo "<td width='280'><a href='message_show.php?
m_id=".$row['m_id']."'>";
echo $row['m_title']."</a></td>";
}

//判断m_content字段内字符值是否包含<br>字符串
if(stristr($row['m_content'],"<br>"))
{
echo "<td widch='300'><a href='message_show.php? m_id=".$row['m_id']."'>";
echo strlen($row['m_content'],0,0-strlen(strstr($row['m_content'],"<br>")))."...</a></td>";
}
else
{
echo "<td witch='300'><a href='message_show.php?
m_id=".$row['m_id']."'>";
echo $row['m_content']."</a></td>";
}
echo "<td width='60' align='center'><a href='mailto:".$row['m_mail']."'>".$row['m_user']."</a></td>";
//仅选取m_time字段内16个字符的数据
echo"<th width='130' align='center'>".substr($row['m_time'],0,16)."</th>";
echo"</th>";
$j=$i+1;
}
}


}
?>
</table>
<br>
<table width="406" border="0" align="center">
<tr>
<td align="center">
<!---将p值设为0,让模块从第一条数据开始取---->
<a href="message_list.php?p=0">第一页</a>
</td>
<td align="center">
<?php
if($p>9)//判断是否有上一页
{
$last=f(floor($j/10)*10)-10;
echo"<a href='message_list.php?p=$last'>上一页</a>";
}

else echo"上一页";
?>
</td>
<td align="center">
<?php
if($i>9 and $num>$check)//判断是否有下一页
echo "<a href='message_list.php?p=$j'>下一页</a>";
else
echo "下一页";
?>
</td>
<td align="center";>
<?php
if($i>9)//判断目前显示的条数之后是否还有页面
{
//取得最后一页的第一条数据
$final=floor($num/10)*10;
echo "<a href='message_list.php?p=$final'>最后一页</a>";
}
else
echo "最后一页";
?>

</td>
</tr>
</table>




message_process.php
<?php
 include("db_conn.php");
 include("db_func.php");
 
 function changword($newword)
  {
   $newword=str_replace("\r\n","<br>",newword);//将enter转化为<br>
   $newword=str_replace("[']+","'",newword);//将[']+转换为'
   return $newword;
  }
  $time=date("Y-m-d g:i:s");
  $ip=$REMOTE_ADDR;
  //处理留言者发布的留言操作
  if($check==add)
  {
   $SQLstr="INSERT INTO message(m_title,m_content,m_time,m_user,m_mail,m_pass,m_ip)";
   $SQLstr="VALUES('$title','".changword($content)."','$time','$user','$email','$pass','$ip')";
   $message="增加留言成功";
   echo"good";
   }
   
   
   if($check==upd)
   {
     include("id_check.php");//外挂身份检查元件
    $SQLstr="UPDATE message SET m_title='$title',m_content='".changword($content)."',m_time='$time',";
 $SQLstr.="m_mail='$email',m_ip='$ip' WHERE m_id='$m_id'";
 $message="更新留言完成!";
   }
  if($check==del)
  {
    include("id_check.php");//外挂身份检查元件
    $SQLstr="DELETE FROM message WHERE m_id=$m_id";
 $message="删除留言成功";
 db_query($SQLstr);
  }
 ?>
 
 <script>
 alert("<?php echo $message;?>");
 location.href="message_list.php?p=0";
 </script>
   
   
message_post.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>留言发布</title>
</head>
<body>
<form name="form1" method="post" action="message_process.php?check=add">
 <table width="481" border="1" cellpadding="0" cellspacing="0" align="center">
  <tr>
   <td>
    <table width="480" border="0" align="center" cellpadding="1" bordercolor="#99FFFF" cellpadding="1">
     <tr>
      <td height="10" colspan="2" bgcolor="#00FF99">
      <div align="center"><font color="#FFCCCC" size="4">
      访问者留言板</font></div>
      </td>
      </tr>
      <tr>
     <td height="30" bgcolor="#9933CC">
     <div align="center">留言人</div>
     </td>
     <td height="30" bgcolor="#0033FF">
     <input type="text" name="user" size="20">
     </td>
     </tr>
     <tr>
     <td height="23">
     <div align="center">e-mail</div>
     </td>
     <td height="23">
     <input type="text" name="email" size="36">
     </td>
     </tr>
     <tr>
     <td height="23" bgcolor="#99ccff">
     <div align="center">留言主题</div>
     </td>
     <td height="23" bgcolor="#33CCCC">
     <input type="text" name="title" size="36">
     </td>
     </tr>
     <tr>
     <td height="80">
     <div align="center">留言内容</div>
     </td>
     <td height="80">
     <p>
     <textarea name="content" rows="10" cols="35">
     </textarea>
     <br>
     </p>
     </td>
     </tr>
     <tr>
     <td height="25" colspan="2" bgcolor="#993333">
     <div align="center">
     <input type="reset" name="Reset" value="清除重填">
     <input type="submit" name="Submit" value="送出留言">
     </div>
     </td>
     </tr>
     <tr>
     <td height="80" align="center">留言密码</td>
     <td height="80">
     <input type="password" name="pass" size="20" maxlength="20">
     </td>
     </tr>
     
     </table>
     </td>
     </tr>
     </table>
     </form>
     
     
     
     
</body>
</html>
搜索更多相关主题的帖子: 留言 
2009-09-24 21:33
shenyulv
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:166
专家分:150
注 册:2009-3-8
收藏
得分:0 
哎,,,,,,,,,

叶的离去,是风的过错,还是树的不挽留?
2009-09-28 23:49
风月_无边
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:60
帖 子:2960
专家分:652
注 册:2007-1-19
收藏
得分:10 
你这么问问题 ,别人是无从下手的 ,你要首先自己测试一下是哪里的问题。
首先,你说的发表的留言无法显示,
发表有没有成功?
数据库中能写入吗,不能就要检查process页面,
如果能写入就是显示页面有问题,检查list页面。

我的网站 http://www.
2009-09-29 11:58
笨笨林
Rank: 6Rank: 6
等 级:贵宾
威 望:21
帖 子:482
专家分:408
注 册:2007-7-28
收藏
得分:10 
是呀,先查看一下数据库中有没有被写入。再确定问题所在。

程序授权说明:http://www./authorization.php  无路难开路难。  帮助别人是快乐的,也只有帮助别人,才能得到别人的帮助。互相帮助,才能共同进步。
2009-09-30 11:29
快速回复:留言板无法正确发布
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015680 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved