Text-based visitor sign-in book_PHP tutorial

WBOY
Release: 2016-07-21 16:05:51
Original
768 people have browsed it

By chance, I saw someone on the Internet using PHP+MYSQL to make a guest sign-in book. I thought it was very useful, so I wanted to make one myself. But using MYSQL felt a bit overkill, so I built a text-based visitor sign-in book. Its function is similar to what I saw on the Internet using MYSQL. I will publish its source code here, hoping that it will help netizens learn PHP. It is limited to my level, so there must be bugs in it, and I hope friends don’t forget to tell me if they find it. This sign-in book consists of two files: one is the sign.txt file that stores the sign-in information, which can be created by NOTEPAD; the second is the sign.php file that processes the information. There is a demo of it on Bamboo Garden's homepage , you are welcome to take a look.下面
就是sign.php的源代码:
sign.php
if(isset($name)&&isset($msg)){
   $name=ltrim($name);
   $t=date(y年m月d日);
   $dat="[".$t."]";
   $msg=ltrim($msg);
   $name=trim($name);
   $msg=trim($msg);
   $pristr=$name."  ".$dat." ".$msg."n";
   $f=fopen("sign.txt","a");
   fwrite($f,$pristr);
   fclose($f);
   }
   $file=file("sign.txt");
    if(!isset($pagenum)){
      $pagenum=1;
    }
    $lesssign=0;
    $num=count($file);
    $dispnumed=6*($pagenum-1);
    $dispnumbeg=$num-$dispnumed;
    $artnumeof1=6*$pagenum;
    $isdispnum=$num-$artnumeof1;
     if($isdispnum<=0){
      $dispnumeof=1;
      $lesssign=1;
    }
    else{
      $dispnumeof=$isdispnum+1;
    }
    $sign=0;
    $pagec=0;
     for($icount=0;($icount<$num)&&($sign==0);$icount+=6){
      for($i=0;$i<=6;$i++){
       if(($icount*6+$i)==$num){
           $sign=1;
         }
       }
       $pagec++;
     }
    $pagecount=$pagec;
    echo"

";
    $fuhao="◇  ";
    $color=e9eae9;
    $iscolor=0;
    $lessnum=5;
    echo"";
    for($i=$dispnumbeg;$i>=$dispnumeof;$i--){
       $linknum=$num-$i;
       $lessnum--;
       $stringmsg1=$file[($i-1)];
       $stringmsg2=strrev($stringmsg1);
       $stringmsg3=strstr($stringmsg2,"psbn");
       $stringmsg=strrev($stringmsg3);
       $stringlink=strstr($file[($i-1)],"http");
       $dispvar=$fuhao.$stringmsg;
       echo"";
       if($iscolor==0){
         $color=ffffff;
         $iscolor=1;
       }
       else{
         $color=e9eae9;
         $iscolor=0;
       }
    }
    if($lesssign==1){
         for($iless=$lessnum;$iless>0;$iless--){
       echo"";
          if($iscolor==0){
         $color=ffffff;
         $iscolor=1;
       }
       else{
         $color=e9eae9;
         $iscolor=0;
       }
       }
    }
    echo"";
    echo"";
    echo"";
    echo"";
    echo"";

    echo"
";
    echo"斑竹园签到簿";
    echo"
";
       echo$dispvar;
       echo "";
       echo"";
       echo$stringlink;
       echo"
";
       echo"
";
       echo $fuhao."
n";
       echo"
";
    echo"称呼:";
    echo"";
    echo"地址:";
    echo"";
    echo"";
    echo"
";
   ?> 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/315547.htmlTechArticle一个很偶然的机会,在网上看到了有人用PHP+MYSQL作了一个访客签到簿, 当时觉得很有用处所以自己也很 想搞一个。但是用MYSQL觉得有点在材...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template