| 一个可分页的基于文本的PHP留言板 |
|
| 作者:未知 文章来源:网络收集 点击数: 更新时间:2006-3-9 12:14:27
|
小弟初学PHP,编了一个留言板程序,自我感觉良好,故厚着脸皮放了上来,请各位大哥指正。源程序如下: <?php //文件名:guest.php //设定部分 $guestfile="guest";//纪录留言的文本文件 $home="index.html";//返回的主页 $imagedir="image"; //图像文件的目录 $backimage=$imagedir."/bk.gif";//背景图像 $backcolor="#ceffff";//背景颜色,在$backimage=""时起作用 ?> <html> <head> <?php if($QUERY_STRING!="") { $page = $QUERY_STRING; } else { $page = 1; } if($mode=="add"){ $name=htmlspecialchars(trim($name)); $title=htmlspecialchars(trim($title)); $data=nl2br(htmlspecialchars($data)); $data=str_replace("r","",$data); $data=str_replace("x0A","",$data); $data=str_replace(" "," ",$data); if($data=="") $data=" "; $e_mail=trim($e_mail); if($e_mail=="") $e_mail=0; $url=trim($url); if($url=="http://" || $url=="") $url=0; $time=date("Y")."年".date("m")."月".date("d")."日[".date("H").":".date("i").":".date("s")."]"; if($name=="" || $title==""){ echo "<script Language="Javascript">n"; echo " alert("请至少输入姓名与留言标题。");n"; echo "history.back();"; echo "</script></head></html>n"; exit; } $adddata=$name."t".$e_mail."t".$url."t".$title."t".$data."t".$icon."t".$time."n"; if(file_exists($guestfile)){ $filebuffer=file($guestfile); if(sizeof($filebuffer)>100){ for($i=0;$i<100;$i++) $newbuffer[i]=$filebuffer[i]; } else{ $newbuffer=$filebuffer; } $fp=fopen($guestfile,"w"); fputs($fp,$adddata); fclose($fp); $buffer=implode("",$newbuffer); $fp=fopen($guestfile,"a"); fputs($fp,$buffer); fclose($fp);
} else{ $fp=fopen($guestfile,"w"); fwrite($fp,$adddata); fclose($fp); } } ?> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"> <title>留言板</title> <style> a{text-decoration:none; font-size:9pt; color:blue} a:visited {text-decoration:none; color:009999} a:hover {color:red; text-decoration:underline} td{font-size:9pt;line-height:14pt} P{font-size:9pt} </style> </head> <?php if($backimage!="" && file_exists($backimage)){ echo "<body background="".$backimage."" bgproperties="fixed">n"; } else{ echo "<body bgcolor="".$backcolor."">n"; } ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#9999FF"> <td height="28"> <div align="center"><b>供电9901网上空间留言板</b></div> </td> </tr> <tr><td><div align="right"><a href="<? echo $home; ?>">[返回首页]</a></div></td&g[1] [2] [3] [4] 下一页
|
|
[ 收藏此页到: 天天|和讯|博采|ViVi|狐摘|我摘|天极 ] 文章录入:kinda 责任编辑:kinda |
|
上一篇文章: 用PHP制作的意见反馈表 下一篇文章: 采用行写方式的聊天程序(之五) |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |