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

2016-01-29 14:36 3 1 收藏

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

【 tulaoshi.com - PHP 】

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

<?
   if ($Submit)
   {
if ($SavePassword=="on")
{setcookie("TxtPassword","$TxtPassword",time()+30*24*3600);}
else
{setcookie("TxtPassword");}
   }
?
<html
<style type=text/css
Td {FONT-SIZE: 10pt;}
TEXTAREA
{
FONT-FAMILY: "宋体";
FONT-SIZE: 10pt;
}

</style
<head
<meta http-equiv="Content-Language" content="zh-cn"
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"
<title修改留言</title
<?
require("sys.php");
function readvalue($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;
}

function save($record)
{
global $TxtContent,$TxtEmail,$TxtHomepage,$TxtEmail,$TxtName,$TxtFrom,$TxtReply,$REMOTE_ADDR,$guestfile;
$content=file($guestfile,"r");
$space = "&nbsp;";
$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 = "<tr<td<font color=#AB00E1留言内容:</font<br<!--content$TxtContent<!--endcontent ";
$Wcontent=$Wcontent."<br<font color=#6633FF留言人大名:</font<!--name$TxtName<!--endname ";
if ($TxtEmail !="")
{$Wcontent=$Wcontent."<br<font color=#9900CC电子信箱</font<a href="mailto:$TxtEmail"<!--email$TxtEmail<!--endemail</a"."$space";}
if ($TxtHomepage !="http://")
{$Wcontent=$Wcontent."<font color=#9900CC主页:</font$TxtHompage<a href="$TxtHomepage" target=new<!--homepage$TxtHomepage<!--endhomepage</a";}
$Wcontent=$Wcontent."<br<font color=#0000FF时间:$time 来自:<!--from$TxtFrom<!--endfrom ".$ip."</font";
$Wcontent=ereg_replace(chr(10),"",$Wcontent);
$Wcontent=$Wcontent."<hr size=1</td</tr";
$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(""","&quot;",$txtreply);
if ($Submit)
  {
  if ($TxtPassword==$managepwd)
  {
  i

来源:https://www.tulaoshi.com/n/20160129/1493736.html

延伸阅读
标签: Web开发
最近一直在用php+dbfile开发blog,开发过程中学到了不少东西,于是就试着写了一个小留言本。 这个留言本采用php+dbfile,不需要使用数据库,可以放在blog中使用,比如http://www.customyze.com,这个blog中的Tag Board就是这个留言本。 整个留言本需要四个文件,分别是:board.php、index.php、config.php、admin.php。 board.php用来存储...
标签: PHP
      小弟初学PHP,编了一个留言板程序,自我感觉良好,故厚着脸皮放了上来,请各位大哥指正。源程序如下: <?php //文件名:guest.php //设定部分 $guestfile="guest";//纪录留言的文本文件 $home="index.html";//返回的主页 $imagedir="image"; //图像文件的目录 $backim...
标签: PHP
  guestbook.php: <head <meta http-equiv="Content-Language" content="zh-cn" <meta http-equiv="Content-Type" content="text/html; charset=gb2312" <title</title <STYLEA:link {         COLOR: #002878; TEXT-DECORATI...
PS:本文留言本并不是什么完美版本,如果你只想拿来使用不建议用此源文件,但是如果你想学习flash留言本的制作原理,可能此文对你有极大的帮助! 其他flash留言本原文件可以去此处下载 flash+php+mysql简单留言本教程 目的 : 用flash+php+mysql制作一个简单的留言本。 配置环境 : 最开始肯定是先配置相应的环境了。我下载的是配置环境套...
标签: PHP
post.php 文件 <?php require('config.php'); ?   <?php $nikename=$arr_request['nikename']; if (strlen($nikename)==0) { echo "<center"; echo "<h2<font color=red错误信息!</font</h2"; echo "对不起,<font color=red呢称</font必须填写!!! 请重...

经验教程

754

收藏

9
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部