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

Source: Internet
Author: User

The younger brother was a beginner in PHP and compiled a message board program. He felt good about himself, so he put his face up. please correct me. The source program is as follows:
<? Php
// File name: guest. php
// Settings
$ Guestfile = "guest"; // record the text file of the message
$ Home = "index.html"; // return to the home page
$ Imagedir = "image"; // image file directory
$ Backimage = $ imagedir. "/bk.gif"; // background image
$ Backcolor = "# ceffff"; // background color, which takes effect when $ 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 "). "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 the 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) & gt; 100 ){
For ($ I = 0; I 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, "");
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>
</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> power supply 9901 online space message board </B> </div>
</Td>
</Tr>
<Tr> <td> <div align = "right"> <a href = "<? Echo $ home;?> "> [Back to homepage] </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 = "20">
<Br>
E_Mail:
<Input type = "text" name = "e_mail" size = "20">
<Br>
Home page:
<Input type = "text" name = "url" value = "http: //" size = "30">
<Br>
Message Title:
<Input type = "text" name = "title" size = "50">
<Br>
Message content: (HTML is not supported) <br>
<Textarea name = "data" rows = "5" cols = "60"> </textarea>
<Div id = "Layer1" style = "position: absolute; left: 460px; top: 152px; width: 301px; height: pixel PX; z-index: 1">
<P> emotion: </p>
<P>
<Input type = "radio" name = "icon" value = "1">
"Width =" 15 "height =" 15 ">
<Input type = "radio" name = "icon" value = "2">
"Width =" 15 "height =" 15 ">
<Input type = "radio" name = "icon" value = "3">
"Width =" 15 "height =" 15 ">
<Input type = "radio" name = "icon" value = "4" checked>
"Width =" 15 "height =" 15 ">
<Input type = "radio" name = "icon" value = "5">
"Width =" 15 "height =" 15 ">

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.