Php text message board

Source: Internet
Author: User
This article will share with you the code of the message board made using php in combination with text files. it is very simple and implements common functions. we recommend it to you for your reference. The code is very simple, so we don't need to talk nonsense. we can directly provide the code:

Del. php

The code is as follows:





My message board



<? Php include ("menu. php");?>
Delete message
<? Php
$ Id = $ _ GET ["id"];
$ Info = file_get_contents ("liuyan.txt ");
$ Lylist = explode ("@", $ info );
Unset ($ lylist [$ id]);
$ Ninfo = implode ("@", $ lylist );
File_put_contents ("liuyan.txt", $ ninfo );
$ Alert = "alert ('deleted successfully! ')";
Echo "script". $ alert. "script";
?>



DoAdd. php

The code is as follows:





My message board



<? Php include ("menu. php");?>
Add message
<? Php
// Obtain the message board information
$ Title = $ _ POST ["title"];
$ Author = $ _ POST ["author"];
$ Content = $ _ POST ["content"];
$ Time = time ();
$ Ip = $ _ SERVER ["REMOTE_ADDR"];
$ Ly = "{$ title }##{$ author }##{$ content }#{$ time }##{$ ip }@@@";
Echo $ ly;
$ Ly = $ ly. file_get_contents ("liuyan.txt ");
File_put_contents ("liuyan.txt", $ ly );
$ Alert = "alert ('message successful! Thank you! ')";
Echo "script". $ alert. "script;"
?>



Index. php

The code is as follows:





My message board



<? Php include ("menu. php");?>
Add message




Liuyan.txt

The code is as follows:


Anshen ###### 1426588557 #127.0.0.1 @@@

Show. php

The code is as follows:





My message board



<? Php include ("menu. php");?>
Add message































<? Php$ Info = file_get_contents ("liuyan.txt ");If ($ info = null ){$ Alert = "alert ('no message! ')";Echo "script". $ alert. "script";}Else {$ Info = rtrim ($ info ,"@");$ Lylist = explode ("@", $ info );Foreach ($ lylist as $ key => $ v ){$ Ly = explode ("#", $ v );Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";}}?>
Message title Contact Message content Message time IP address Operation
$ Ly [0]$ Ly [1]$ Ly [2]". Date (" Y-m-d H: I: s ", $ ly [3] + 8x3600 )."$ Ly [4]Delete




Menu. php

The code is as follows:


My message board
Add message
View messages


The above is all the content of this article. I hope you will like it.

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.