Home  >  Article  >  Backend Development  >  An example of a text guestbook made in PHP (5)_PHP Tutorial

An example of a text guestbook made in PHP (5)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 16:06:16784browse

现在我们来讲一下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]."



  
  
    
            if ($Submit)
       {
        if ($replyname=="" or $replycontent=="")
        {
      echo" ";
      echo"";
      echo"";
       }
       }
      ?>
        
        
        
      
        
        
      
        
        
      
        
        
      
    
    
";
      echo "出错了回复人姓名和回复内容必填!";
      echo"
回复大名  
          
        
  
          

回复内容


          
  
          
        
  
          
          >
          
               
          
        
   
            



------------------
到此为止,php的代码我们已经写完,剩下的是您要作一个留言本的本头和底部
您可以设计任何的样式.不过记得在本头上面要有至少3个连接:查看 返回主页  
发邮件.这样您的留言本系统才算完整.不过由于这是一文本的留言本,所以您不用担心数据库的问题,您只要再写一个guest.txt的文件就完整了.虽然这个留言本没有mysql等等,可是功能仍然不错.而且是完全属于您自己的留言本.好了,下一节我们将为您讲述guest.txt的建立和上传留言本的几个重要步骤.
未完待续...

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/315491.htmlTechArticle现在我们来讲一下reply.php的代码: --------------------------------- //reply.php ? function check_strlen_long($txt) { $len=strlen($txt); $count=0; for ($i=0;$i$len;$i++) {...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn