Home > php教程 > php手册 > body text

php制作文本式留言板

WBOY
Release: 2016-06-06 20:06:28
Original
1380 people have browsed it

本文给大家分享的是使用php结合文本文件制作的留言板的代码,非常简单,实现了常用的功能,推荐给大家,有需要的小伙伴参考下吧。

代码很简单,就不多废话了,直接奉上代码:

del.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('删除成功!')";
     echo "<script>".$alert."</script>";
    ?>



doAdd.php

复制代码 代码如下:





我的留言板



   
   

添加留言


        //获取留言板的信息
    $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('留言成功!谢谢!')";
    echo "<script>".$alert."</script>;"
    ?>  



index.php

复制代码 代码如下:





我的留言板



   
   

添加留言


   

   
   
       
       
   
   
       
       
   
   
       
       
   
   
       
   
   
标题:
留言者:
留言内容:

                  
       
       

   




liuyan.txt

复制代码 代码如下:


安神######1426588557##127.0.0.1@@@

show.php

复制代码 代码如下:





我的留言板



   
   

添加留言


   
       
           
           
           
           
           
           
       
                $info=file_get_contents("liuyan.txt");
        if($info==null){
            $alert="alert('无留言信息!')";
            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 "";
        }
        }
        ?>
   
留言标题 留言人 留言内容 留言时间 IP地址 操作
$ly[0]$ly[1]$ly[2]".date("Y-m-d H:i:s",$ly[3]+8*3600)."$ly[4]删除




menu.php

复制代码 代码如下:

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!