Little Brother Beginner PHP, made up a message board program, I feel good, so thick shameless put up, please big Brother correct me. The source program is as follows:
<?php
FileName: guest.php
Settings section
$guestfile = "Guest";//Record message text file
$home = "index.html";//home page returned
$imagedir = "image"; Directory of image files
$backimage = $imagedir. " /bk.gif ";//Background image
$backcolor = "#ceffff";//Background color, function when $backimage= ""
?>
<?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"). " Year ". Date (" M ")." Month ". Date (" D ")." Day [". Date (" H ").": ". Date (" I ").": ". Date (" S ").
if ($name = = "" | | $title = = "") {
echo "<script language=" JavaScript ">n";
echo Alert (Please enter at least the name and message title.) "); n";
echo "History.back ();";
echo "</script>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> Message Board </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>
<?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= ">"
<div align= "center" ><b> Power 9901 online space message board </b></div>
</td>
</tr>
<tr><td><div align= "right" ><a href= " echo $home?> ">[back home]</a></div></td></tr>
</table>
<font size= "2" >
<form method= "POST" action= "guest.php" >
<input type= "hidden" name= "mode" value= "Add" >
<p> Name:
<input type= "text" name= "name" size= ">
<br>
E_Mail:
<input type= "text" name= "E_Mail" size= ">"
<br>
Home:
<input type= "text" name= "url" value= "http://" size= ">"
<br>
Message title:
<input type= "text" name= "title" Size= ">"
<br>
Message content: (HTML not supported) <br>
<textarea name= "Data" rows= "5" cols= "></textarea>"
<div id= "Layer1" style= "Position:absolute; left:460px; top:152px; width:301px; height:104px; Z-index:1 ">
<p> expression:</p>
<p>
<input type= "Radio" name= "icon" value= "1" >
<input type= "Radio" name= "icon" value= "2" >
<input type= "Radio" name= "icon" value= "3" >
<input type= "Radio" name= "icon" value= "4" checked>
<input type= "Radio" name= "icon" value= "5" >
current 1/2 page
1 2 Next read the full text