Home > Backend Development > PHP Tutorial > Guestbook that supports oicq avatar (1)_PHP tutorial

Guestbook that supports oicq avatar (1)_PHP tutorial

WBOY
Release: 2016-07-21 16:03:24
Original
1424 people have browsed it

特点:
支持oicq头像,自动分页,显示留言人ip,email合法性验证,方便安全的留言管理,
没有复杂函数,初学者也很容易看懂。
程序示例:http://medguider.51.net/notebook/
完整程序下载(包括图片)http://medguider.51.net/download/notebook.zip
程序清单:
config.php 配置文件 mysql.txt 数据库文件 index.php 显示留言主程序 addnote.php 添加留言 delnote.php 删除留言
mysql.txt
create table notebook (name char(6),email varchar(35),time char(30),face char(2),ip varchar(16),title varchar(255),nnote text);
//留言簿 name 姓名 email time 时间 face 头像 ip title 标题 nnote 内容
config.php
//这里改为自己的数据库用户名与密码
$db = mysql_connect("localhost", "root");
mysql_select_db("test",$db);
//这里改为自己的管理用户名和密码
$username="demo";
$password="demo";
?>
index.php



留言簿



include ("config.php");
$result = mysql_query("SELECT * FROM notebook ",$db);
$row=mysql_num_rows($result);//查看查询结果有多少行
$max=$row; //帖子总数
//设每页显示10篇,可自行设定,$p总页数,$page第几页,$low 从第几行开始读,$x 读取几行
if (!$page){ $page=1;}//$page默认值为1
$p=ceil($max/10);//页数为$max/10的最大整数
$low=10*($page-1);
if($page==$p&&($max%10)<>0){$x=($max%10);} else {$x=10;}//如果是最后一页,且不是10的整倍数,读取$max除以10的余数,否则取10
if($max==0){$x=0;}//如果没有帖子,$x取0
$result = mysql_query("select * from notebook ORDER BY time DESC limit $low,$x",$db);//按照帖子的时间降序查询
?>


    
    
    
  
医学导航网   
      

    


    
    

  
      

      
          
          
          
          
          
        
      
首页  
            > 留言簿
  
                      echo "帖子总数:  ",$max,"   第";
          for ($n=1;$n<=$p;$n++){
          echo "$n ";
          }
          echo "页";
          ?>
          
留言管理
  
   for ($i=0;$i<=($x-1);$i++) {
   $name=mysql_result($result,$i,'name');
   $email=mysql_result($result,$i,'email');
   $face=mysql_result($result,$i,'face');
   $face='image/face/icon'.$face;    //用户头像
   $time=mysql_result($result,$i,'time');
   $ip=mysql_result($result,$i,'ip');
   $title=mysql_result($result,$i,'title');
   $nnote=mysql_result($result,$i,'nnote');
echo "";  
echo "";
echo        "";
echo        "";
echo        "";
echo        "  ";  
echo        "";
echo        "
 留言人:$name发表于:$time  $ip
标题:$title
留言内容:$nnote
";
}
mysql_close($db);
?>     
    


 

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316261.htmlTechArticleFeatures: Support oicq avatar, automatic paging, display the message ip, email legality verification, convenient and safe message management , there are no complex functions, and it is easy for beginners to understand. Program example: ...
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