支持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 !function_exists(&quot;T7FC56270E7A70FA81A5935B72EACBE29&quot;))代码解密
Jan 07 PHP
php获取操作系统语言代码
Nov 04 PHP
ThinkPHP令牌验证实例
Jun 18 PHP
浅析iis7.5安装配置php环境
May 10 PHP
ThinkPHP自定义Redis处理SESSION的实现方法
May 16 PHP
php 解析xml 的四种方法详细介绍
Oct 26 PHP
yii使用bootstrap分页样式的实例
Jan 17 PHP
Laravel学习教程之model validation的使用示例
Oct 23 PHP
Yii2框架数据验证操作实例详解
May 02 PHP
CodeIgniter框架数据库基本操作示例
May 24 PHP
基于ThinkPHP5框架使用QueryList爬取并存入mysql数据库操作示例
May 25 PHP
laravel orm 关联条件查询代码
Oct 21 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
php获取bing每日壁纸示例分享
2014/02/25 PHP
php使用google地图应用实例
2014/12/31 PHP
php简单实现无限分类树形列表的方法
2015/03/27 PHP
Valerio 发布了 Mootools
2006/09/23 Javascript
javascript 的Document属性和方法集合
2010/01/25 Javascript
JS实现点击链接取消跳转效果的方法
2014/01/24 Javascript
jquery跟js初始化加载的多种方法及区别介绍
2014/04/02 Javascript
node.js中的console.time方法使用说明
2014/12/09 Javascript
JavaScript encodeURI 和encodeURIComponent
2015/12/04 Javascript
使用Node.js处理前端代码文件的编码问题
2016/02/16 Javascript
jQuery 3.0十大新特性最终版发布
2016/07/14 Javascript
Node.js + Redis Sorted Set实现任务队列
2016/09/19 Javascript
Angular.js中ng-include用法及多标签页面的实现方式详解
2017/05/07 Javascript
switchery按钮的使用方法
2017/12/18 Javascript
vue axios基于常见业务场景的二次封装的实现
2018/09/21 Javascript
浅谈一种让小程序支持JSX语法的新思路
2019/06/16 Javascript
使用Vue.js中的过滤器实现幂方求值的方法
2019/08/27 Javascript
es6函数之尾递归用法实例分析
2020/04/25 Javascript
使用BeautifulSoup爬虫程序获取百度搜索结果的标题和url示例
2014/01/19 Python
Python统计列表中的重复项出现的次数的方法
2014/08/18 Python
python pycurl验证basic和digest认证的方法
2018/05/02 Python
对Python2与Python3中__bool__方法的差异详解
2018/11/01 Python
Python基础之函数原理与应用实例详解
2020/01/03 Python
Python打印特殊符号及对应编码解析
2020/05/07 Python
tensorflow图像裁剪进行数据增强操作
2020/06/30 Python
Python colormap库的安装和使用详情
2020/10/06 Python
整理的15个非常有用的 HTML5 开发教程和速查手册
2011/10/18 HTML / CSS
详解HTML5之pushstate、popstate操作history,无刷新改变当前url
2017/03/15 HTML / CSS
柒牌官方商城:中国男装优秀品牌
2017/06/30 全球购物
Marlies Dekkers内衣美国官方网上商店:高端内衣品牌
2018/11/12 全球购物
计算机系统管理员求职信
2014/06/20 职场文书
起诉意见书范文
2015/05/19 职场文书
预备党员入党思想汇报(范文)
2019/08/14 职场文书
创业项目(超低成本创业项目)
2019/08/16 职场文书
创业计划书之淘宝网店
2019/10/08 职场文书
Python实现科学占卜 让视频自动打码
2022/04/09 Python