PHP text message board source code

Source: Internet
Author: User
PHP text message board source code PHP text message board-code sharing


Index. php (home page)




US-Japan message board www.hnzyxok.com





Add message





DoAddLiuYan. php (add comments)



US-Japan message board www.hnzyxok.com





Add message
// Add the message

// 1. obtain the message to be added and add other auxiliary information (IP address, add time)
$ Title = $ _ POST ["title"]; // Obtain the message title
$ Author = $ _ POST ["author"]; // get the message recipient
$ Content = $ _ POST ["content"]; // message content
$ Ip = $ _ SERVER ["REMOTE_ADDR"]; // ip address
$ Addtime = time (); // add time (timestamp)

// 2. assembly (assembly) message
$ Ly = "{$ title }##{$ author }##{$ content }#{$ ip }##{$ addtime }@@@";
// Echo $ ly;
// 3.add the message information to the liuyan.txt file
$ Info = file_get_contents ("liuyan.txt"); // Obtain all previous messages and write them in the latest value.
File_put_contents ("liuyan.txt", $ info. $ ly); // rewrite the function to overwrite
// 4. The message is successfully output!
Echo "message successful! Thank you! ";
?>





Menu. php (navigation bar)

US-Japan message board www.hnzyxok.com
Add a message |
View messages



Delete. php (delete message)



US-Japan message board www.hnzyxok.com





Delete message
// Delete the message of the specified id.
// 1. obtain the ID number of the message to be deleted
$ Id = $ _ GET ["id"];

// 2.obtain the message information from the message liuyan.txt file.
$ Info = file_get_contents ("liuyan.txt ");

// 3. split the message with the symbol @ into a message array
$ Lylist = explode ("@", $ info );

// 4. use unset to delete the message with the specified id
Unset ($ lylist [$ id]);

// 5. restore the message as a string and write back the message file: liuyan.txt
$ Ninfo = implode ("@", $ lylist );
File_put_contents ("liuyan.txt", $ ninfo );
// 6.
Echo "deleted successfully! ";
?>





Show. php (show messages)




US-Japan message board www.hnzyxok.com
Script
// Define the js code to be deleted.
Function dodel (id ){
If (confirm ("Are you sure you want to delete it? ")){
Window. location = 'Del. php? Id = '+ id;
}
}
Script





View messages





































// Obtain the message and parse it and output it to the table.// 1.obtain the message information from the message liuyan.txt file.$ Info = file_get_contents ("liuyan.txt "); // 2. retrieve the last three symbols of the message content$ Info = rtrim ($ info ,"@");If (strlen ($ info)> 8 ){// 3. split the message with the @ symbol as one.// (Split the message with the symbol @ into a message array)$ Lylist = explode ("@", $ info );// Var_dump ($ lylist );// 4. traverse the message array and parse each message againForeach ($ lylist as $ k => $ v ){$ Ly = explode ("#", $ v); // splits each message into each field #Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";// Echo $ v ."";}//}?>
Message title Contact Message content IP address Message time Operation
{$ Ly [0]}{$ Ly [1]}{$ Ly [2]}{$ Ly [3]}". Date (" Y-m-d H: I: s ", $ ly [4] + 8x3600 )."Delete




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.