Home > Backend Development > PHP Tutorial > A paginated text-based PHP message board_PHP tutorial

A paginated text-based PHP message board_PHP tutorial

WBOY
Release: 2016-07-13 17:31:43
Original
789 people have browsed it

​                                                                                                         I just started learning php (as the current mainstream development language)  , but I compiled a message board program and felt good about myself, so I posted it shamelessly and asked for your corrections. The source program is as follows:
(as the current mainstream development language)
//File name: guest.php(as the current mainstream development language)
//Setting section
$guestfile="guest";//Text file to record comments
$home="index.html";//Returned homepage
$imagedir= "image"; //Directory of image files
$backimage=$imagedir."/bk.gif";//Background image
$backcolor="#ceffff";//Background color, in $backimage= It works when "" 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")."Year".date("m")."Month".date("d")."Day[".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);
}
}
? >

Message Board
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}


(as the current mainstream development language)

if($backimage!="" && file_exists($backimage)){
echo "n";
}
else{
echo "n" ; }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509056.htmlTechArticleI am new to PHP (as the current mainstream development language), and compiled a message board program, and I feel good about myself. So I put it up shamelessly, please correct me. The source program is as follows: ?p...
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