分类广告


推荐文章

  • 没有找到任何内容!
您当前的位置:中国站长下载网络编程PHP专区 → 文章内容

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

  • 作者:佚名    来源:不详    发布时间:2006-2-26 2:02:47
  • 字体大小:
特点

支持oicq头像
自动分页显示留言人ipemail合法性验证方便安全的留言管理

没有复杂函数
初学者也很容易看懂。

程序示例
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>

&gt; 留言簿</td>

<td width="48%" class="white12" height="23">

<?php

echo "帖子总数: &nbsp;",$max," &nbsp;&nbsp;第";

for ($n=1;$n<=$p;$n++){

echo "<a href=index.php?page=$n>$n</a>&nbsp;";

}

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'>&nbsp;<img src='http://www.chinaitpower.com/A/2001-12-12/$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='http://www.chinaitpower.com/A/2001-12-12/image/email.gif' width='16' height='16' border=0></a></td>";

echo "<td width='21%' height='33' class='blue9'><img src='http://www.chinaitpower.com/A/2001-12-12/image/ip.gif' width='13' height='15'> &nbsp;$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>
<