支持oicq头像的留言簿(一)


Posted in PHP onOctober 09, 2006

特点:
支持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
<?php
//这里改为自己的数据库用户名与密码
$db = mysql_connect("localhost", "root");
mysql_select_db("test",$db);
//这里改为自己的管理用户名和密码
$username="demo";
$password="demo";
?>
index.php
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>留言簿</TITLE>
<style type="text/css">
<!--
.blue9 {  font-size: 9pt; color: #0099FF; text-decoration: none}
.black9 {  font-size: 9pt; text-decoration: none}
.purple10 {  font-size: 10pt; color: #9900FF; text-decoration: none}
.white12 {  font-size: 12pt; color: #FFFFFF; text-decoration: none}
a:visited {  color: #FFFFFF}
a:link {  color: #FFFFFF}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<?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);//按照帖子的时间降序查询
?>
<table width="98%" border="0" cellspacing="0" cellpadding="0" height="61">
  <tr>  
    <td height="62" width="34%"><a href="http://www.medguider.com"><img src="image/logo.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
    <td height="62" width="66%">  
      <div align="center"><img src="image/note.gif" width="410" height="60"><img src="image/y1.gif" width="60" height="60"></div>
    </td>
  </tr>
</table>
<table width="95%" border="1" cellspacing="0" cellpadding="0" height="253" bordercolordark="#FFFFFF" bordercolorlight="#003399" align="center">
  <tr>  
    <td height="250">  
      <div align="center"></div>
      <table width="95%" border="0" cellspacing="0" cellpadding="0" height="32" bgcolor="#3366FF">
        <tr>  
          <td width="26%" class="white12" height="23"><a href="../index.php" class="white12">首页</a>  
            > 留言簿</td>
          <td width="48%" class="white12" height="23">  
            <?php
          echo "帖子总数:  ",$max,"   第";
          for ($n=1;$n<=$p;$n++){
          echo "<a href=index.php?page=$n>$n</a> ";
          }
          echo "页";
          ?>
          </td>
          <td width="15%" height="23"><a href="addnote.php"><img src="image/newthread.gif" width="91" height="21" border="0"></a></td>
          <td width="11%" height="23"><a href="delnote.php"><span class="white12">留言管理</span></a></td>
        </tr>
      </table>  
<?php
   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 "<table width='100%' border='0' cellspacing='0' cellpadding='0' height=107' bordercolor='#FFFFFF'> <tr bgcolor='#eeeeee'>";  
echo "<td width='10%' height='33' bgcolor='#eeeeee' class='blue9'> <img src='$face.gif' width='32' height='32'></td>";
echo        "<td width='16%' height='33' bgcolor='#eeeeee' class='blue9'>留言人:$name</td>";
echo        "<td width='41%' height='33' bgcolor='#eeeeee' class='blue9'>发表于:$time</td>";
echo        "<td width='12%' height='33' bgcolor='#eeeeee' class='blue9'><a href='mailto:$email'><img src='image/email.gif' width='16' height='16' border=0></a></td>";
echo        "<td width='21%' height='33' class='blue9'><img src='image/ip.gif' width='13' height='15'>  $ip</td>  </tr> <tr>";  
echo        "<td colspan='5' class='purple10' height='33'>标题:$title</td> </tr>";
echo        "<tr bgcolor='#ffffff'><td colspan='5' class='black9' height='37'>留言内容:$nnote</td></tr></table>";
}
mysql_close($db);
?>     
    </td>
</tr>
</table>
</BODY>
</HTML> 

PHP 相关文章推荐
PHP企业级应用之常见缓存技术篇
Jan 27 PHP
PHP 无限分类三种方式 非函数的递归调用!
Aug 26 PHP
PHP获取浏览器信息类和客户端地理位置的2个方法
Apr 24 PHP
php中get_cfg_var()和ini_get()的用法及区别
Mar 04 PHP
PHP使用Face++接口开发微信公众平台人脸识别系统的方法
Apr 17 PHP
功能强大的php分页函数
Jul 20 PHP
php根据命令行参数生成配置文件详解
Mar 15 PHP
实例说明js脚本语言和php脚本语言的区别
Apr 04 PHP
Swoole 5将移除自动添加Event::wait()特性详解
Jul 10 PHP
Thinkphp自定义生成缩略图尺寸的方法
Aug 05 PHP
关于laravel 数据库迁移中integer类型是无法指定长度的问题
Oct 09 PHP
修改Laravel自带的认证系统的User类的命名空间的步骤
Oct 15 PHP
NT IIS下用ODBC连接数据库
Oct 09 #PHP
怎样在UNIX系统下安装php3
Oct 09 #PHP
怎样在UNIX系统下安装MySQL
Oct 09 #PHP
关于文本留言本的分页代码
Oct 09 #PHP
支持oicq头像的留言簿(二)
Oct 09 #PHP
一个ubbcode的函数,速度很快.
Oct 09 #PHP
PHP中动态HTML的输出技术
Oct 09 #PHP
You might like
fleaphp下不确定的多条件查询的巧妙解决方法
2008/09/11 PHP
PHP 简单日历实现代码
2009/10/28 PHP
php利用imagemagick实现复古老照片效果实例
2017/02/16 PHP
PHP的mysqli_rollback()函数讲解
2019/01/23 PHP
纯JavaScript实现获取onclick、onchange等事件的值
2014/12/29 Javascript
JSON字符串和对象相互转换实例分析
2016/06/16 Javascript
jQuery绑定自定义事件的魔法升级版
2016/06/30 Javascript
Vue.js计算属性computed与watch(5)
2016/12/09 Javascript
jQuery实现的手风琴侧边菜单效果
2017/03/29 jQuery
jQuery Validate 无法验证 chosen-select元素的解决方法
2017/05/17 jQuery
JS实现上传图片的三种方法并实现预览图片功能
2017/07/14 Javascript
详解Javascript中new()到底做了些什么?
2018/03/29 Javascript
浅谈Vue组件及组件的注册方法
2018/08/24 Javascript
vue 项目build错误异常的解决方法
2019/04/22 Javascript
Node.JS在命令行中检查Chrome浏览器是否安装并打开指定网址
2019/05/21 Javascript
中级前端工程师必须要掌握的27个JavaScript 技巧(干货总结)
2019/09/23 Javascript
vue-router为激活的路由设置样式操作
2020/07/18 Javascript
vue.js 解决v-model让select默认选中不生效的问题
2020/07/28 Javascript
Python urllib、urllib2、httplib抓取网页代码实例
2015/05/09 Python
python+PyQT实现系统桌面时钟
2020/06/16 Python
Pycharm连接远程服务器过程图解
2020/04/30 Python
Python+PyQt5实现灭霸响指功能
2020/05/25 Python
python进行OpenCV实战之画图(直线、矩形、圆形)
2020/08/27 Python
利用HTML5中Geolocation获取地理位置调用Google Map API在Google Map上定位
2013/01/23 HTML / CSS
什么是动态端口(Dynamic Ports)?动态端口的范围是多少?
2014/12/12 面试题
小学教师的自我评价范例
2013/10/31 职场文书
校园门卫岗位职责
2013/12/09 职场文书
大学生职业规划前言模板
2013/12/27 职场文书
擅自离岗检讨书
2014/02/11 职场文书
我爱我家教学反思
2014/05/01 职场文书
大二学年个人总结
2015/03/03 职场文书
邮政营业员岗位职责
2015/04/14 职场文书
年会邀请函的格式及范文五篇
2019/11/02 职场文书
python实现图片九宫格分割的示例
2021/04/25 Python
python 如何在list中找Topk的数值和索引
2021/05/20 Python
mysql 体系结构和存储引擎介绍
2022/05/06 MySQL