PHP+TEXT留言本(一)
大家知道,數據庫對于網絡來說的重要性.由于cgi的復雜,現在asp和php+mysql已經成為主流.幾乎所有的個人網頁都要用到留言本,可是申請的留言本很不穩定.這為網上的交流帶來了諸多不便.所以,希望擁有自己的留言本的朋友越來越多.但是,免費的個人主頁支持asp和php的很少.筆者現在向您推薦動站指南,(http://www.mypchelp.cn)支持php.這樣您便有了能夠擁有自己留言本的基礎.現在,我就通過一個文本留言本的例子來講述php的簡單使用.
首先,我們先確定,留言的幾個過程:寫留言,發送,查看.(搜索)等等.而且對于斑竹來說,管理留言本又是不可或缺的.這樣我們就不妨定位于6個php文件,1個文本文件.6個php文件分別為:guest.php manage.php reply.php sys.php del.php edit.php,1個文本文件為:guest.txt
先來看看guest.php的內容,你當然可以直接將下面的內容放到您的php網頁里,請尊重作者的勞動,謝謝.----------------------//guest.php:<?
require('sys.php');if ($B1){ if($message=='' or $name=='') { $errorm='<font color=red>出錯了!!!</font>姓名和留言內容必填'; } else{#寫入數據$space = ' ';$time = date(Y年m月d日H小時i分);$ip=$REMOTE_ADDR;$name=encode($name);$homepage=encode($homepage);$from=encode($from);$email=encode($email);$message=StripSlashes($message);$message=htmlspecialchars($message);$message=check_strlen_long($message);$message=nl2br($message);$guestcontent = '<tr><td><font color=#AB00E1>留言內容:</font><br><!--content>$message<!--endcontent> ';$guestcontent=$guestcontent.'<br><font color=#6633FF>留言人大名:</font><!--name>$name<!--endname> ';if ($email !=''){$guestcontent=$guestcontent.'<br><font color=#9900CC>電子信箱</font><a href='