del.php
The code is as follows:
<meta charset= "Utf-8" >
<title> My message Board </title>
<body>
<center>
<?php include ("menu.php");?>
<?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 (' Delete succeeded! ‘)";
echo "<script>". $alert. " </script> ";
?>
</center>
</body>
doadd.php
The code is as follows:
<meta charset= "Utf-8" >
<title> My message Board </title>
<body>
<center>
<?php include ("menu.php");?>
<?php
Get information about the message board
$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>; "
?>
</center>
</body>
index.php
The code is as follows:
<meta charset= "Utf-8" >
<title> My message Board </title>
<body>
<center>
<?php include ("menu.php");?>
<form action= "doadd.php" method= "POST" >
<table width= ">"
<tr>
<TD align= "right" > title:</td>
<td><input type= "text" name= "title"/></td>
</tr>
<tr>
<TD align= "Right" > Message:</td>
<td><input type= "text" name= "author"/></td>
</tr>
<tr>
<TD align= "right" valign= "top" > Message content:</td>
<td><textarea name= "Content" rows= "5" cols= "></textarea></td>"
</tr>
<tr>
<TD colspan= "2" align= "Center" >
<input type= "Submit" value= "Submission" >
<input type= "reset" value= "reset" >
</td>
</tr>
</table>
</form>
</center>
</body>
Liuyan.txt
The code is as follows:
Soothing ##### #1426588557 ##[email protected]@@
show.php
The code is as follows:
<meta charset= "Utf-8" >
<title> My message Board </title>
<body>
<center>
<?php include ("menu.php");?>
<table border= "1" >
<tr>
<th> Message title </th>
<th> Message Person </th>
<th> Message Content </th>
<th> Message Time </th>
<th>ip Address </th>
<th> Operations </th>
</tr>
<?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 "<tr>";
echo "<td aligh= ' center ' > $ly [0]</td>";
echo "<td aligh= ' center ' > $ly [1]</td>";
echo "<td aligh= ' center ' > $ly [2]</td>";
echo "<td>". Date ("Y-m-d h:i:s", $ly [3]+8*3600). </td> ";
echo "<td> $ly [4]</td>";
echo "<td><a href= ' del.php?id={$key} ' > Delete </a></td>";
echo "</tr>";
}
}
?>
</table>
</center>
</body>
menu.php
The code is as follows:
<H2 color= "Blue" > My message Board <a href= "index.php" > Add a Message </a>
<a href= "show.php" > View message </a>
Make a simple text message board with PHP