一个php作的文本留言本的例子(五)

这一节自己将为大家陈诉关于guest.txt的确立艺术和上传的有关事项. ——-
//guest.txt trtdfont
color=#AB00E1留言内容:/fontbr!–contentzihanonline!–endcontent brfont
color=#6633FF留言人民代表大会名:/font!–namezihanonline!–endname font
color=#9900CC主页:/fonta href=
target=new!–homepage!–endhomepage/abrfont
color=#0000FF时间:2001年4月15日14小时06分 来自:!–from!–endfrom
xx.x.x.x/fonthr size=1/td/tr ——-
方面是一个guest.txt的写入例子,您能够将他们放上去,然后看一看效果,再拓宽谐和个性化的改正.遵纪守法的实践是最最主要的.
一切都办好了,剩下的正是上传了.小编以cuteftp为例,当您将全体都传到你的主页空间后,您须要有两个接连指向guest.php.那样您才干够让主页和留言本结合起来,其它一个最最根本的是,您要将guest.txt文件的天性改为666,那也是已经折磨了我好一段日子的难题.具体做法是:上传了guest.txt后用鼠标右键点击
guest.txt后现身一串菜单选项,选CHMOD项,在manual方框内添入666,点分明,好了,大功告成.您能够大饱眼福具有协调的留言本的乐趣了.
全文完

世家清楚,数据库对于网络来讲的入眼性.由于cgi的头晕目眩,以往asp和php+mysql已经济体改为主流.大约具备的私人商品房网页都要用到留言本,但是申请的留言本特别不牢固.那为网上的沟通带来了好些个不便.所以,希望全体和谐的留言本的爱人尤为多.
不过,无需付费的个人主页帮助asp和php的相当少.我未来向你推荐奥索网,(卡塔尔辅助php.那样您便有了能够具有协调留言本的功底.以往,小编就经过一个文书留言本的例子来说述php的轻松利用.
首先,大家先分明,留言的多少个经过:写留言,发送,查看.(寻觅State of Qatar等等.何况对于斑竹来讲,管理留言本又是必备的.那样大家就不要紧定坐落于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 ($B1State of Qatar {
if($message== or $name==State of Qatar { $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 = trtdfont
color=#AB00E1留言内容:/fontbr!–content$message!–endcontent ;
$guestcontent=$guestcontent.brfont
color=#6633FF留言人民代表大会名:/font!–name$name!–endname ; if ($email !=)
{$guestcontent=$guestcontent.brfont color=#9900CC电子信箱/fonta
href=/mailto:$email/!–email$email!–endemail/a.$space;} if ($homepage
!=) {$guestcontent=$guestcontent.font color=#9900CC主页:/font$hompagea
href=/$homepage/!–homepage$homepage!–endhomepage/a;}
$guestcontent=$guestcontent.brfont color=#0000FF时间:$time
来自:!–from$from!–endfrom $ip/font;
$guestcontent=ereg_replace(chr(10),,$guestcontent);
$guestcontent=$guestcontent.hr size=1/td/tr/n; $fp=fopen($guestfile,a);
fputs($fp,$guestcontent); fclose($fp); } } ? html head
titlezihanonlinegbook/title style !– A:link {text-decoration: none ;
color:0000ff} A:visited {text-decoration: none; color:004080} A:active
{text-decoration: none} A:hover {text-decoration: underline;
color:ff0000} BODY {FONT-SIZE:10pt} TH {FONT-SIZE:10 pt} TD {FONT-SIZE:
10pt} TEXTAREA { FONT-FAMILY: 宋体; FONT-SIZE: 10pt; } — /style body
bgcolor=#FFFFFD background=bg.jpg div align=center?
include(‘head.htm’);? table width=68% border=1 cellpadding=3
cellspacing=0 bordercolor=#E3E3E3 form method=POST action=guest.php ?
if ($errorm) { echo tr; echo td colspan=3 height=32 ; echo $errorm; echo
/td; echo /tr; } ?trtd width=22% bgcolor=#F0F0F0font
color=#000000姓名font color=#FF0033(必填)/font/font/td td colspan=2
width=78% bgcolor=#F0F0F0font color=#00FF00input type=text name=name
size=40 /font/td /tr trtd width=22% height=29主页:/td td colspan=2
height=29 width=78%input type=text name=homepage size=40 value= /td /tr
trtd width=22% height=27 bgcolor=#F0F0F0来自:/td td colspan=2 height=27
width=78% bgcolor=#F0F0F0input type=text name=from size=40 /td /tr trtd
width=22% height=20Email:/td td colspan=2 height=20 width=78%font
color=#00FF00input type=text name=email size=40 /font/td /tr trtd
colspan=3 valign=middle align=leftdiv align=centerfont
color=#000000请留言/fontfont color=#FF0033(必填)/fontfont
color=#00FF00br textarea rows=6 name=message cols=55
wrap=VIRTUAL/textarea /font/div /td /tr tr bgcolor=#F0F0F0td colspan=3
height=24div align=centerfont color=#00FF00input type=submit value=发送
name=B1 input type=reset value=重 写 name=B2 /font/div /td /tr /form
/table table width=68% border=1 cellpadding=4 cellspacing=0
bordercolor=#E3E3E3 trtd table width=百分百 border=0 cellpadding=0
cellspacing=0 form action=manage.php method=post trtd colspan=2input
type=hidden name=dispflag value=show 管理密码:inputtype=password
name=password size=8 input type=submit value=分明 name=submit /td /tr
/form /table /td td table width=百分之百 border=0 cellpadding=0
cellspacing=0 form action=guest.php method=post trtd 请输加入关贸总协定组织键字:input
type=text name=keyword size=10 input type=submit name=search
value=搜索留言 /td /tr /form /table /td /tr /table ? function
search($keyword卡塔尔国 { global $content; $count=count($content卡塔尔;
$subscript=0; $ArrSearch=array(卡塔尔(قطر‎; for ($i=0;$i$count;$i++卡塔尔 { if
(ereg($keyword,$content[$i])){
$ArrSearch[$subscript]=ereg_replace($keyword,font
color=red$keyword/font,$content[$i]); $subscript++; } } return
$ArrSearch; }//end function $one_page_line=15; $content =
file($guestfile); if (isset($search) and isset($keyword) and $keyword!=)
{ $content=search($keyword); } $count =count($content); ? table
width=68% border=0 tr td ? $int_page_count=$count;//总条数;
$int_page_num=ceil($int_page_count/$one_page_line);//总页数; echo
font color=#CC33FF分页:; for ($i=1;$i=$int_page_num;$i++) { echo a
href=guest.php?page=$i.$i./a; } echo /font; if (isset($search) and
isset($keyword) and $keyword!=卡塔尔(قطر‎ { echo brcenter; echo
上边包车型地铁留言中含有关键字font color=red$keyword/font共font
color=red.$count./font条/center; } ? /tdtdp align=right共有font
color=red?echo $count?/font条/p/td /tr /table /div br table width=68%
border=0 align=center ? if ($page== or !isset($page)) {$page=1;} $text=;
$begin_line=$int_page_count-($page-1)*$one_page_line; if
($begin_line$one_page_line){$one_page_line=$begin_line;} for
($j=$begin_line;$j($begin_line-$one_page_line);$j–) {
$text=$text.trtd align=right colspan=2a
href=reply.php?job=reply&record=.$j.回复/aa
href=edit.php?record=.$j.编辑/aa href=dele.php?record=.$j.删除/a第font
color=red$j/font条/td/tr; $text.=$content[$j-1]; //数组找下标从0开头.
} echo $text; ? /table ? include(‘bottom.htm’卡塔尔国; ? /body/html
—————— 未完待续…

现行反革命大家来说一下reply.php的代码: ———————————
//reply.php ? function check_strlen_long($txt) { $len=strlen($txt);
$count=0; for ($i=0;$i$len;$i++) { if (ord($txt[$i])128) {
$count=$count+1;} if (ord($txt[$i])==10 or ord($txt[$i])==32)
{$count=0;} if ($count=60){ $txt[$i]=n; $count=0; } } return $txt; }
function encode ($txt) { $txt=strip_tags($txt);
$txt=htmlspecialchars($txt); $message=StripSlashes($txt); return
$message; } $content=file(guest.txt); $disptext=$content[$record-1];
if ($job==addreply and $replyname!= and $replycontent!=) {
$content=file(guest.txt); $count=count($content); $time =
date(Y年m月d日H小时i分); $ip=$REMOTE_ADDR;
$replycontent=StripSlashes($replycontent);
$replyname=encode($replyname);
$replycontent=htmlspecialchars($replycontent);
$replycontent=check_strlen_long($replycontent);
$replycontent=nl2br($replycontent);
$replycontent=ereg_replace(chr(10),,$replycontent);
$content[$record-1]=substr($content[$record-1],0,strlen($content[$i])-1);
$content[$record-1]=$content[$record-1].!–replytrtd colspan=4ulfont
color=#AB00E1回复内容:/fontbr.$replycontent.br回复人民代表大会名:.$replyname.brfont
color=#CC33FF时间:$time 来自:$ip/font/ulhr size=1 color=blue/td/trn;
$fp=fopen(guest.txt,w); for ($i=0;$i$count;$i++) {
fputs($fp,$content[$i],strlen($content[$i])); } echo meta
content=1;url=guest.php; exit; } ?titlezihanonline/title style !–
A:link {text-decoration: none ; color:0000ff} A:visited
{text-decoration: none; color:004080} A:active {text-decoration: none}
A:hover {text-decoration: underline; color:ff0000} BODY {FONT-SIZE: 10p}
TH {FONT-SIZE: 10pt} TD {FONT-SIZE: 10pt} — /style body
bgcolor=#FFFFFF background=back.gif div ? include(‘head.htm’);? table
border= 1width= 65%height= 169 cellpadding=8 cellspacing=0
bordercolor=#E3E3E3 form method= POSTaction=reply.php ? if ($Submit) {
if ($replyname== or $replycontent==) { echotr align=left valign=middle
bgcolor=#F0F0F0 ; echotd width= 百分百height= 31 ; echo font
color=red出错了/font回复人姓名和重振旗鼓内容必填!; echo/td; echo/tr; } } ? ?
echo $disptext ?tr align=left valign=middle bgcolor=#F0F0F0td width=
100%height= 31 bgcolor=#FFFFFF 回复大名input type= textname=
replynamesize= 20 /td /tr tr valign=middletd width= 百分之百height= 26align=
left bgcolor=#f0f0f0 p回复内容/p /td /tr tr align=centertd width=
百分之百height= 52valign= top bgcolor=#FFFFFF textarea rows= 6name=
replycontentcols= 46 wrap=VIRTUAL /textarea /td /tr tr valign=middle
align=center bgcolor=#F0F0F0td width= 100%height= 14 bgcolor=#f0f0f0
input type=hidden name=job value=addreply input type=hidden name=record
value=? echo $record ? input type= submitvalue= 提交name=Submit input
type=reset value= 重写name= B2 /td /tr /form
/table?include(‘bottom.htm’State of Qatar;?/div /body /html ——————
到此结束,php的代码我们早已写完,剩下的是您要作三个留言本的本头和底部您能够设计任何的样式.可是记得在本头上边要有起码3个一而再再而三:查看
重临主页发邮件.那样您的留言本系统才算完整.但是由于这是一文件的留言本,所以你不用担忧数据库的标题,您假如再写叁个guest.txt的文书就全部了.固然这几个留言本未有mysql等等,不过功效依旧不错.并且是完全归于您自个儿的留言本.好了,下一节大家将为您陈说guest.txt的创造和上传留言本的几个至关心爱戴要步骤.
未完待续…

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图