search
Homephp教程php手册一个可分页的基于文本的PHP留言板

一个可分页的基于文本的PHP留言板

Jun 13, 2016 am 10:30 AM
phpmainstreamPaginationCanbased ondeveloptextnowmessage boardoflanguage

    小弟初学php(做为现在的主流开发语言),编了一个留言板程序,自我感觉良好,故厚着脸皮放了上来,请各位大哥指正。源程序如下:
(做为现在的主流开发语言)
//文件名:guest.php(做为现在的主流开发语言)
//设定部分
$guestfile="guest";//纪录留言的文本文件
$home="index.html";//返回的主页
$imagedir="image"; //图像文件的目录
$backimage=$imagedir."/bk.gif";//背景图像
$backcolor="#ceffff";//背景颜色,在$backimage=""时起作用
?>


(做为现在的主流开发语言)
if($QUERY_STRING!="") {
  $page = $QUERY_STRING;
} else {
  $page = 1;
}
if($mode=="add"){
  $name=htmlspecialchars(trim($name));
  $title=htmlspecialchars(trim($title));
  $data=nl2br(htmlspecialchars($data));
  $data=str_replace("r","",$data);
  $data=str_replace("x0A","",$data);
  $data=str_replace(" "," ",$data);
  if($data=="") $data=" ";
  $e_mail=trim($e_mail);
  if($e_mail=="") $e_mail=0;
  $url=trim($url);
  if($url=="http://" || $url=="") $url=0;
  $time=date("Y")."年".date("m")."月".date("d")."日[".date("H").":".date("i").":".date("s")."]";
  if($name=="" || $title==""){
    echo "n";
    exit;
  }
  $adddata=$name."t".$e_mail."t".$url."t".$title."t".$data."t".$icon."t".$time."n";
  if(file_exists($guestfile)){
    $filebuffer=file($guestfile);
    if(sizeof($filebuffer)>100){
      for($i=0;$i        $newbuffer[i]=$filebuffer[i];
    }
    else{
      $newbuffer=$filebuffer;
    }
    $fp=fopen($guestfile,"w");
    fputs($fp,$adddata);
    fclose($fp);
    $buffer=implode("",$newbuffer);
    $fp=fopen($guestfile,"a");
    fputs($fp,$buffer);
    fclose($fp);

  }
  else{
    $fp=fopen($guestfile,"w");
        fwrite($fp,$adddata);
        fclose($fp);
  }
}
?>

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment