书签 分享 收藏 举报 版权申诉 / 32

类型PHP留言板.docx

  • 文档编号:23826591
  • 上传时间:2023-05-21
  • 格式:DOCX
  • 页数:32
  • 大小:24.03KB

   

管理密码:

 

请输入关键字:

functionsearch($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,"$keyword",$content[$i]);

$subscript++;

}

}

return$ArrSearch;

}//endfunction

$one_page_line=15;

$content=file($guestfile);

if(isset($search)andisset($keyword)and$keyword!

="")

{

$content=search($keyword);

}

$count=count($content);

?

>

$int_page_count=$count;//总条数;

$int_page_num=ceil($int_page_count/$one_page_line);//总页数;

echo"分页:

";

for($i=1;$i<=$int_page_num;$i++)

{

echo"

page=$i>".$i." ";

}

echo"";

if(isset($search)andisset($keyword)and$keyword!

="")

{

echo"

";

echo"下面的留言中包含关键字$keyword共".$count."条

";

}

?

>

共有

echo"$count"?

>条


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."

job=reply&record=".$j.">回复 

record=".$j.">编辑 

record=".$j.">删除 第$j条";

$text.=$content[$j-1];

//数组找下标从0开始.

}

echo"$text";

?

>

include('bottom.htm');

?

>

上一次我们研究了guest.php文件.具体的问题还要求读者朋友自己深入的去实践,而且需要一些工具书来学习,如果您一点php的知识都没有,笔者奉劝您就不要想下看了,笔者没有太多的时间和篇幅去逐句探究一个php文件的用途和意义.好的,接下来我们来作edit.php这个文件.

-----------

//edit.php

if($Submit)

{

if($SavePassWord=="on")

{setcookie("TxtPassword","$TxtPassword",time()+30*24*3600);}

else

{setcookie("TxtPassword");}

}

?

>

Td{FONT-SIZE:

10pt;}

TEXTAREA

{

FONT-FAMILY:

"宋体";

FONT-SIZE:

10pt;

}

修改留言

require("sys.php");

functionreadvalue($tags,$tage)

{

global$message,$long,$reply;

$StrStart=strlen(strstr($message,$tags))-strlen($tags);//去除标记后变量所在字串的起始位置.

$StrEnd=strlen(strstr($message,$tage));

$len=$StrStart-$StrEnd;

$StrStart=$long-$StrStart;//起始字符.

$StrString=substr($message,$StrStart,$len);

return$StrString;

}

functionsave($record)

{

global$TxtContent,$TxtEmail,$TxtHomepage,$TxtEmail,$TxtName,$TxtFrom,$TxtReply,$REMOTE_ADDR,$guestfile;

$content=file($guestfile,"r");

$space=" ";

$time=date(Y年m月d日H小时i分);

$ip=$REMOTE_ADDR;

$TxtReply=StripSlashes($TxtReply);

$TxtContent=StripSlashes($TxtContent);

$TxtContent=htmlspecialchars($TxtContent);

$TxtContent=check_strlen_long($TxtContent);

$TxtContent=nl2br($TxtContent);

$Wcontent="留言内容:


--content>$TxtContent

--endcontent>";

$Wcontent=$Wcontent."
留言人大名:

--name>$TxtName

--endname>";

if($TxtEmail!

="")

{$Wcontent=$Wcontent."
电子信箱

$TxtEmail">

--email>$TxtEmail

--endemail>"."$space";}

if($TxtHomepage!

="http:

//")

{$Wcontent=$Wcontent."主页:

$TxtHompage

--homepage>$TxtHomepage

--endhomepage>";}

$Wcontent=$Wcontent."
时间:

$time来自:

--from>$TxtFrom

--endfrom>".$ip."";

$Wcontent=ereg_replace(chr(10),"",$Wcontent);

$Wcontent=$Wcontent."";

$TxtReply=ereg_replace(chr(10),"",$TxtReply);

$WContent=$Wcontent.$TxtReply."n";

$count=count($content);

$fp=fopen($guestfile,"w");

for($i=0;$i<$count;$i++)

{

if($i==$record-1)

{$content[$i]=$WContent;}

fputs($fp,$content[$i]);

}

fclose($fp);

}

$content=file($guestfile,"r");

$message=$content[$record-1];

$long=strlen($message);

$txtcontent=readvalue('

--content>','

--endcontent>');

$txtname=readvalue('

--name>','

--endname>');

$txtfrom=readvalue('

--from>','

--endfrom>');

$txtemail=readvalue('

--email>','

--endemail>');

$txthomepage=readvalue('

--homepage>','

--endhomepage>');

$txtcontent=strip_tags($txtcontent);

$tags="

--reply>";

$txtreply=strstr($message,$tags);

$txtreply=ereg_replace(""",""",$txtreply);

if($Submit)

{

if($TxtPassword==$managepwd)

{

if($TxtName!

=""and$TxtContent!

="")

{

save($record);

echo"";

exit;

}else{$errorm="留言人姓名和内容必填!

!

";}

}

else{$errorm="密码错误,只有管理员有权修改!

!

";}

}

?

>

include('head.htm');?

>

if($errormand$Submit)

{

echo"";

echo"";

echo"出错了,$errorm";

echo"";

echo"";

}

?

>

留言大名

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
PHP 留言板
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:PHP留言板.docx
链接地址:https://www.bdocx.com/doc/23826591.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开