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
Message Title |
Contact |
Message Content |
Message time |
IP address |
Operation |
<? 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"
$ Ly [0] | ";Echo"
$ Ly [1] | ";Echo"
$ Ly [2] | ";Echo"
". Date (" Y-m-d H: I: s ", $ ly [3] + 8x3600 )." | ";Echo"
$ Ly [4] | ";Echo"
Delete | ";Echo"
";}}?>
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.