Home > Backend Development > PHP Tutorial > A paging text-based PHP message board source code page 1/2_PHP tutorial

A paging text-based PHP message board source code page 1/2_PHP tutorial

WBOY
Release: 2016-07-21 15:56:27
Original
1213 people have browsed it

小弟初学PHP,编了一个留言板程序,自我感觉良好,故厚着脸皮放了上来,请各位大哥指正。源程序如下: 
//文件名:guest.php
//设定部分
$guestfile="guest";//纪录留言的文本文件
$home="index.html";//返回的主页
$imagedir="image"; //图像文件的目录
$backimage=$imagedir."/bk.gif";//背景图像
$backcolor="#ceffff";//背景颜色,在$backimage=""时起作用
?> 
 
 
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 "

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);
}
}
?> 
 
留言板 
 
 
if($backimage!="" && file_exists($backimage)){
echo "n"; 

else{ 
  echo "n"; 

?> 
 
   
     
   
 
 
      
供电9901网上空间留言板
 
    
">[返回首页]
 
 
 
   
  

姓名: 
     
    
 
    E_Mail: 
     
    
 
    主页: 
     
    
 
    留言标题: 
     
    
 
    留言内容:(不支持HTML)
 
     
   
    

表情:

 
    

 
       
      " width="15" height="15"> 
       
      " width="15" height="15"> 
       
      " width="15" height="15"> 
       
      " width="15" height="15"> 
       
      " width="15" height="15">

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/318062.htmlTechArticle小弟初学PHP,编了一个留言板程序,自我感觉良好,故厚着脸皮放了上来,请各位大哥指正。源程序如下: ?php //文件名:guest.php //设定部分...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template