PHP text-style message board source code

Source: Internet
Author: User
Tags add time
PHP Text Message board--code sharing


index.php (Home)




U.S.-Japan Exchange message Board www.hnzyxok.com





Add message







doaddliuyan.php (Add message)



U.S.-Japan Exchange message Board www.hnzyxok.com





Add message


Perform message add action

1. Get the message you want to add and fill in additional information (IP address, add time)
$title = $_post["title"]; Get the message title
$author = $_post["Author"]; Get the message to the person
$content = $_post["Content"]; Message content
$ip = $_server["REMOTE_ADDR"]; IP Address
$addtime = time (); Add Time (timestamp)

2. Assembling (assembling) message information
$ly = "{$title}##{$author}##{$content}##{$ip}##{$addtime}@@@";
Echo $ly;
3. Append the message to the Liuyan.txt file
$info = file_get_contents ("Liuyan.txt");//Get all previous messages in the latest value stitching to write
File_put_contents ("Liuyan.txt", $info. $ly);//change function is overwrite write
4. Output Message Success!
echo "The message was successful! Thank you! ";
?>





menu.php (nav bar)

U.S.-Japan Exchange message Board www.hnzyxok.com


Add Message |
View Message


delete.php (Delete message)



U.S.-Japan Exchange message Board www.hnzyxok.com





Delete message


Executes a message that deletes the specified ID.
1. Get the ID number of the message you want to delete
$id = $_get["id"];

2. Get message information from message liuyan.txt information file
$info = file_get_contents ("Liuyan.txt");

3. Split the message into a message array with the @@@ 的
$lylist = Explode ("@@@", $info);

4. Use unset to delete a message with the specified ID
Unset ($lylist [$id]);

5. Restore the message to a string, and write back to the message file: Liuyan.txt
$ninfo = Implode ("@@@", $lylist);
File_put_contents ("Liuyan.txt", $ninfo);
6.
echo "deleted successfully! ";
?>





show.php (Show message)




U.S.-Japan Exchange message Board www.hnzyxok.com






View Message







































Get message information, parse and output to the table. 1. Get message information from message liuyan.txt information file $info = file_get_contents ("Liuyan.txt"); 2. Take out the last three @@@ 符号 $info = RTrim ($info, "@"); if (strlen ($info) >8) {//3. Split the message with the @@@ 符号 as one article. (The message information is broken into the message array by the @@@ 的) $lylist = Explode ("@@@ 的, $info); Var_dump ($lylist); 4. Iterate through the message array and parse each message again foreach ($lylist as $k + $v) {$ly = Explode ("# #", $v);//Send each message message with # #号拆分成每个留言字段 echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo $v. ""; }//}?>
Message title Message Person Message Content IP Address Message Time Operation
{$ly [0]}{$ly [1]}{$ly [2]}{$ly [3]}". Date (" Y-m-d h:i:s ", $ly [4]+8*3600)."Delete




  • Related Article

    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.