PHP 文本式留言板源碼

來源:互聯網
上載者:User
PHP 文本式留言板--代碼分享


index.php(首頁)




美日匯留言板 www.hnzyxok.com





添加留言







doAddLiuYan.php(增加留言)



美日匯留言板 www.hnzyxok.com





添加留言


//執行留言資訊添加操作

//1.擷取要要添加的留言資訊,並且補上其他輔助資訊(ip地址、添加時間)
$title = $_POST["title"]; //擷取留言標題
$author = $_POST["author"]; //擷取留言者
$content = $_POST["content"]; //留言內容
$ip = $_SERVER["REMOTE_ADDR"]; //IP地址
$addtime = time(); //添加時間(時間戳記)

//2.拼裝(組裝)留言資訊
$ly = "{$title}##{$author}##{$content}##{$ip}##{$addtime}@@@";
//echo $ly;
//3.將留言資訊追加到liuyan.txt檔案中
$info = file_get_contents("liuyan.txt");//擷取所有以前的留言,在最新的值拼接寫入
file_put_contents("liuyan.txt",$info.$ly);//改函數是覆蓋寫入
//4.輸出留言成功!
echo "留言成功!謝謝!";
?>





menu.php(導覽列)

美日匯留言板 www.hnzyxok.com


添加留言 |
查看留言


delete.php(刪除留言)



美日匯留言板 www.hnzyxok.com





刪除留言


//執行刪除指定id的留言資訊。
//1.擷取要刪除留言的id號
$id= $_GET["id"];

//2.從留言liuyan.txt資訊檔中擷取留言資訊
$info = file_get_contents("liuyan.txt");

//3.將留言資訊以@@@的符號拆分成留言數組
$lylist = explode("@@@",$info);

//4.使用unset刪除指定id的留言
unset($lylist[$id]);

//5. 還原留言資訊為字串,並寫回留言檔案:liuyan.txt
$ninfo = implode("@@@",$lylist);
file_put_contents("liuyan.txt",$ninfo);
//6.
echo "刪除成功!";
?>





show.php(顯示留言)




美日匯留言板 www.hnzyxok.com






查看留言







































//擷取留言資訊,解析後輸出到表格中。 //1.從留言liuyan.txt資訊檔中擷取留言資訊 $info = file_get_contents("liuyan.txt"); //2.取出留言內容最後的三個@@@符號 $info = rtrim($info,"@"); if(strlen($info)>8){ //3.以@@@符號拆分留言資訊為一條一條的。 // (將留言資訊以@@@的符號拆分成留言數組) $lylist = explode("@@@",$info); //var_dump($lylist); //4.遍曆留言資訊數組,對每條留言做再次解析 foreach($lylist as $k=>$v){ $ly = explode("##",$v);//將每條留言資訊以##號拆分成每個留言欄位 echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; //echo $v.""; } // } ?>
留言標題 留言人 留言內容 IP地址 留言時間 操作
{$ly[0]}{$ly[1]}{$ly[2]}{$ly[3]}".date("Y-m-d H:i:s",$ly[4]+8*3600)."刪除




  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.