支持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项目打包方法
Feb 18 PHP
php ss7.5的数据调用 (笔记)
Mar 08 PHP
php学习笔记 [预定义数组(超全局数组)]
Jun 09 PHP
浅析使用Turck-mmcache编译来加速、优化PHP代码
Jun 20 PHP
解析php dirname()与__FILE__常量的应用
Jun 24 PHP
php使用curl发送json格式数据实例
Dec 17 PHP
浅析php数据类型转换
Jan 09 PHP
PHP同时连接多个mysql数据库示例代码
Mar 17 PHP
ThinkPHP多表联合查询的常用方法
Mar 24 PHP
php微信公众平台开发(三)订阅事件处理
Dec 06 PHP
PHP多进程编程之僵尸进程问题的理解
Oct 15 PHP
php 多进程编程父进程的阻塞与非阻塞实例分析
Feb 22 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
文件上传的实现
2006/10/09 PHP
php判断手机访问还是电脑访问示例分享
2014/01/20 PHP
ThinkPHP调用common/common.php函数提示错误function undefined的解决方法
2014/08/25 PHP
php自动更新版权信息显示的方法
2015/06/19 PHP
PHP计算加权平均数的方法
2015/07/16 PHP
浅谈Javascript嵌套函数及闭包
2010/11/09 Javascript
JS打印gridview实现原理及代码
2013/02/05 Javascript
JS 屏蔽键盘不可用与鼠标右键不可用的方法
2013/11/18 Javascript
nodejs开发微博实例
2015/03/25 NodeJs
表单验证正则表达式实例代码详解
2015/11/09 Javascript
js实现移动端微信页面禁止字体放大
2017/02/16 Javascript
详解JSONObject和JSONArray区别及基本用法
2017/10/25 Javascript
js实现简单数字变动效果
2017/11/06 Javascript
node.js基于express使用websocket的方法
2017/11/09 Javascript
深入剖析Node.js cluster模块
2018/05/23 Javascript
10种JavaScript最常见的错误(小结)
2019/06/21 Javascript
Vue中fragment.js使用方法小结
2020/02/17 Javascript
python中使用百度音乐搜索的api下载指定歌曲的lrc歌词
2014/07/18 Python
在GitHub Pages上使用Pelican搭建博客的教程
2015/04/25 Python
在Python中使用判断语句和循环的教程
2015/04/25 Python
python调用Matplotlib绘制分布点图
2019/10/18 Python
python实现输入的数据在地图上生成热力图效果
2019/12/06 Python
Python解析多帧dicom数据详解
2020/01/13 Python
Django 项目布局方法(值得推荐)
2020/03/22 Python
最简单的matplotlib安装教程(小白)
2020/07/28 Python
CSS3属性 line-clamp控制文本行数的使用
2020/03/19 HTML / CSS
美国家用电器和电子产品商店:Abt
2016/09/06 全球购物
Ryderwear美国官网:澳大利亚高端健身训练装备品牌
2018/04/24 全球购物
英国手工制作的现代与经典的沙发和床:Love Your Home
2020/09/26 全球购物
一个SQL面试题
2014/08/21 面试题
工商管理实习自我鉴定
2013/09/28 职场文书
会计毕业生自荐书
2014/06/12 职场文书
七年级语文教学反思
2016/03/03 职场文书
2019年怎样写好导游词?
2019/07/02 职场文书
golang 实现Location跳转方式
2021/05/02 Golang
python spilt()分隔字符串的实现示例
2021/05/21 Python