当前位置: 首页 > 图文教程 > 网络编程 > PHP > 支持oicq头像的留言簿(二)

PHP
PHP 开发环境的选择、建立及使用(5)
PHP 开发环境的选择、建立及使用(6)
PHP 开发环境的选择、建立及使用(7)
PHP 开发环境的选择、建立及使用(8)
PHP 开发环境的选择、建立及使用(9)
Win2003下APACHE PHP5 MYSQL4 PHPMYADMIN 的简易安装配置
PHP新手上路(八) 文件上传
PHP新手上路(九) 投票系统
PHP新手上路(十) 简易banner动态更替
PHP新手上路(十一) 数据库链接
PHP新手上路(十二)使用PHP来操作Oracle数据库
PHP新手上路(十三)PHP资源
PHP新手上路(十四) 其他杂项
session全教程(一)
session全教程(二)
session全教程(三)
PHP编码规范
第十五节--Zend引擎的发展 -- Classes and Objects in PHP5 [15]
第十四节--命名空间 -- Classes and Objects in PHP5 [14]
第十二节--类的自动加载 -- Classes and Objects in PHP5 [12]

PHP 中的 支持oicq头像的留言簿(二)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 204 ::
收藏到网摘: n/a

addnote.php
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>添加留言</TITLE>
<style type="text/css">
<!--
.white12 { font-size: 12pt; color: #FFFFFF; text-decoration: none}
-->
</style>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<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="/upload/tech/20091012/20091012013351_109a0ca3bc27f3e96597370d5c8cf03d.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
<td height="62" width="66%">
<div align="center"><img src="/upload/tech/20091012/20091012013351_e94550c93cd70fe748e6982b3439ad3b.gif" width="410" height="60"><img src="/upload/tech/20091012/20091012013352_35f4a8d465e6e1edc05f3d8ab658c551.gif" width="60" height="60"></div>
</td>
</tr>
</table>
<?php
include ("config.php");
if ($submit){
$time=date("Y年m月d日 H:i:s A");
$ip=$REMOTE_ADDR;//留言人ip地址
$name=trim($name);
$email=trim($email);
$title=strip_tags($top);
$nnote=nl2br(strip_tags($content));//先去掉html标记,再将换行符转成 <br>。
if (!$name||!$email||!$title||!$nnote){ //检查是否填写完整
echo "对不起,您必须填所有内容!<BR>"."<a href='javascript:history.back()'>返回</a>";
exit; }elseif(!ereg('^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&'*+\/0-9=?A-Z^_`a-z{|}~]+.'.'[-!#$%&'*+\./0-9=?A-Z^_`a-z{|}~]+$',$email) //email合法性验证
){
echo "email不合法!<BR>"."<a href='javascript:history.back()'>返回</a>";
exit;
}
//写入数据库
$sql="INSERT INTO notebook (name,email,time,face,ip,title,nnote) VALUES ('$name','$email','$time','$face','$ip','$title','$nnote')";
$result = mysql_query($sql,$db);
mysql_close($db);
echo "留言成功!";
}
?>
<table width="99%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolor="#3366FF">
<tr bgcolor="#3366FF">
<td width="81%" class="white12" height="26"><a href="../index.php" class="white12">首页</a>
> <a href="index.php" class="white12">留言簿</a>
> 添加留言</td>
<td width="19%" class="white12" height="26"><a href='index.php' class="white12">查看留言</a>
</td>
</tr>
<tr>
<td colspan="2">
<form name="form1" method="post" action="addnote.php">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="54%"> </td>
<td rowspan="2" width="46%">选择一个自己喜欢的头像:<br>
<img src="/upload/tech/20091012/20091012013352_8cb22bdd0b7ba1ab13d742e22eed8da2.gif" width="32" height="32">
<input type="radio" name="face" value="1" checked>
<img src="/upload/tech/20091012/20091012013353_577ef1154f3240ad5b9b413aa7346a1e.gif" width="32" height="32">
<input type="radio" name="face" value="2">
<img src="/upload/tech/20091012/20091012013353_5f2c22cb4a5380af7ca75622a6426917.gif" width="32" height="32">
<input type="radio" name="face" value="3">
<img src="/upload/tech/20091012/20091012013353_f770b62bc8f42a0b66751fe636fc6eb0.gif" width="32" height="32">
<input type="radio" name="face" value="4">
<img src="/upload/tech/20091012/20091012013354_1ff1de774005f8da13f42943881c655f.gif" width="32" height="32">
<input type="radio" name="face" value="5">
<img src="/upload/tech/20091012/20091012013354_f9a40a4780f5e1306c46f1c8daecee3b.gif" width="32" height="32">
<input type="radio" name="face" value="6">
<img src="/upload/tech/20091012/20091012013355_c4ca4238a0b923820dcc509a6f75849b.gif" width="32" height="32">
<input type="radio" name="face" value="7">
<img src="/upload/tech/20091012/20091012013355_170c944978496731ba71f34c25826a34.gif" width="32" height="32">
<input type="radio" name="face" value="8">
<img src="/upload/tech/20091012/20091012013356_8d7d8ee069cb0cbbf816bbb65d56947e.gif" width="32" height="32">
<input type="radio" name="face" value="9">
<img src="/upload/tech/20091012/20091012013356_6a9aeddfc689c1d0e3b9ccc3ab651bc5.gif" width="32" height="32">
<input type="radio" name="face" value="10">
<img src="/upload/tech/20091012/20091012013356_d045c59a90d7587d8d671b5f5aec4e7c.gif" width="32" height="32">
<input type="radio" name="face" value="11">
<img src="/upload/tech/20091012/20091012013357_6f2268bd1d3d3ebaabb04d6b5d099425.gif" width="32" height="32">
<input type="radio" name="face" value="12">
<img src="/upload/tech/20091012/20091012013357_d14220ee66aeec73c49038385428ec4c.gif" width="32" height="32">
<input type="radio" name="face" value="13">
<img src="/upload/tech/20091012/20091012013358_e7f8a7fb0b77bcb3b283af5be021448f.gif" width="32" height="32">
<input type="radio" name="face" value="14">
<img src="/upload/tech/20091012/20091012013358_d81f9c1be2e08964bf9f24b15f0e4900.gif" width="32" height="32">
<input type="radio" name="face" value="15">
<img src="/upload/tech/20091012/20091012013359_66f041e16a60928b05a7e228a89c3799.gif" width="32" height="32">
<input type="radio" name="face" value="16">
<img src="/upload/tech/20091012/20091012013359_25ddc0f8c9d3e22e03d3076f98d83cb2.gif" width="32" height="32">
<input type="radio" name="face" value="17">
<img src="/upload/tech/20091012/20091012013402_210f760a89db30aa72ca258a3483cc7f.gif" width="32" height="32">
<input type="radio" name="face" value="18">
<img src="/upload/tech/20091012/20091012013402_08c5433a60135c32e34f46a71175850c.gif" width="32" height="32">
<input type="radio" name="face" value="19">
<img src="/upload/tech/20091012/20091012013403_eda80a3d5b344bc40f3bc04f65b7a357.gif" width="32" height="32">
<input type="radio" name="face" value="20">
<img src="/upload/tech/20091012/20091012013403_1aa48fc4880bb0c9b8a3bf979d3b917e.gif" width="32" height="32">
<input type="radio" name="face" value="21">
<img src="/upload/tech/20091012/20091012013403_c4ca4238a0b923820dcc509a6f75849b.gif" width="32" height="32">
<input type="radio" name="face" value="22">
<img src="/upload/tech/20091012/20091012013404_85422afb467e9456013a2a51d4dff702.gif" width="32" height="32">
<input type="radio" name="face" value="23">
<img src="/upload/tech/20091012/20091012013405_0bb4aec1710521c12ee76289d9440817.gif" width="32" height="32">
<input type="radio" name="face" value="24">
<img src="/upload/tech/20091012/20091012013408_53c3bce66e43be4f209556518c2fcb54.gif" width="32" height="32">
<input type="radio" name="face" value="25">
<img src="/upload/tech/20091012/20091012013408_68053af2923e00204c3ca7c6a3150cf7.gif" width="32" height="32">
<input type="radio" name="face" value="26">
<img src="/upload/tech/20091012/20091012013408_598b3e71ec378bd83e0a727608b5db01.gif" width="32" height="32">
<input type="radio" name="face" value="27">
<img src="/upload/tech/20091012/20091012013409_e57c6b956a6521b28495f2886ca0977a.gif" width="32" height="32">
<input type="radio" name="face" value="28">
<img src="/upload/tech/20091012/20091012013409_d645920e395fedad7bbbed0eca3fe2e0.gif" width="32" height="32">
<input type="radio" name="face" value="29">
<img src="/upload/tech/20091012/20091012013410_e836d813fd184325132fca8edcdfb40e.gif" width="32" height="32">
<input type="radio" name="face" value="30">
<img src="/upload/tech/20091012/20091012013410_1700002963a49da13542e0726b7bb758.gif" width="32" height="32">
<input type="radio" name="face" value="31">
<img src="/upload/tech/20091012/20091012013411_2d6cc4b2d139a53512fb8cbb3086ae2e.gif" width="32" height="32">
<input type="radio" name="face" value="32">
<img src="/upload/tech/20091012/20091012013411_c5ab0bc60ac7929182aadd08703f1ec6.gif" width="32" height="32">
<input type="radio" name="face" value="33">
<img src="/upload/tech/20091012/20091012013412_b137fdd1f79d56c7edf3365fea7520f2.gif" width="32" height="32">
<input type="radio" name="face" value="34">
<img src="/upload/tech/20091012/20091012013415_5b8add2a5d98b1a652ea7fd72d942dac.gif" width="32" height="32">
<input type="radio" name="face" value="35">
<img src="/upload/tech/20091012/20091012013415_98f13708210194c475687be6106a3b84.gif" width="32" height="32">
<input type="radio" name="face" value="36">
<img src="/upload/tech/20091012/20091012013415_82161242827b703e6acf9c726942a1e4.gif" width="32" height="32">
<input type="radio" name="face" value="37">
<img src="/upload/tech/20091012/20091012013416_fc49306d97602c8ed1be1dfbf0835ead.gif" width="32" height="32">
<input type="radio" name="face" value="38">
<img src="/upload/tech/20091012/20091012013416_28f0b864598a1291557bed248a998d4e.gif" width="32" height="32">
<input type="radio" name="face" value="39">
<img src="/upload/tech/20091012/20091012013417_6a9aeddfc689c1d0e3b9ccc3ab651bc5.gif" width="32" height="32">
<input type="radio" name="face" value="40">
<img src="/upload/tech/20091012/20091012013417_03c6b06952c750899bb03d998e631860.gif" width="32" height="32">
<input type="radio" name="face" value="41">
<img src="/upload/tech/20091012/20091012013417_2b8a61594b1f4c4db0902a8a395ced93.gif" width="32" height="32">
<input type="radio" name="face" value="42">
<img src="/upload/tech/20091012/20091012013418_dd45045f8c68db9f54e70c67048d32e8.gif" width="32" height="32">
<input type="radio" name="face" value="43">
<img src="/upload/tech/20091012/20091012013418_2ca65f58e35d9ad45bf7f3ae5cfd08f1.gif" width="32" height="32">
<input type="radio" name="face" value="44">
<img src="/upload/tech/20091012/20091012013419_0f840be9b8db4d3fbd5ba2ce59211f55.gif" width="32" height="32">
<input type="radio" name="face" value="45">
<img src="/upload/tech/20091012/20091012013419_4daa3db355ef2b0e64b472968cb70f0d.gif" width="32" height="32">
<input type="radio" name="face" value="46">
<img src="/upload/tech/20091012/20091012013420_9ad6aaed513b73148b7d49f70afcfb32.gif" width="32" height="32">
<input type="radio" name="face" value="47">
<img src="/upload/tech/20091012/20091012013420_3c7781a36bcd6cf08c11a970fbe0e2a6.gif" width="32" height="32">
<input type="radio" name="face" value="48">
<img src="/upload/tech/20091012/20091012013423_cfbce4c1d7c425baf21d6b6f2babe6be.gif" width="32" height="32">
<input type="radio" name="face" value="49">
<img src="/upload/tech/20091012/20091012013424_4d5b995358e7798bc7e9d9db83c612a5.gif" width="32" height="32">
<input type="radio" name="face" value="50">
<img src="/upload/tech/20091012/20091012013427_7504adad8bb96320eb3afdd4df6e1f60.gif" width="32" height="32">
<input type="radio" name="face" value="51">
<img src="/upload/tech/20091012/20091012013427_e94550c93cd70fe748e6982b3439ad3b.gif" width="32" height="32">
<input type="radio" name="face" value="52">
<img src="/upload/tech/20091012/20091012013427_0f28b5d49b3020afeecd95b4009adf4c.gif" width="32" height="32">
<input type="radio" name="face" value="53">
<img src="/upload/tech/20091012/20091012013431_1651cf0d2f737d7adeab84d339dbabd3.gif" width="32" height="32">
<input type="radio" name="face" value="54">
<img src="/upload/tech/20091012/20091012013431_dc82d632c9fcecb0778afbc7924494a6.gif" width="32" height="32">
<input type="radio" name="face" value="55">
<img src="/upload/tech/20091012/20091012013432_556f391937dfd4398cbac35e050a2177.gif" width="32" height="32">
<input type="radio" name="face" value="56">
<img src="/upload/tech/20091012/20091012013435_37bc2f75bf1bcfe8450a1a41c200364c.gif" width="32" height="32">
<input type="radio" name="face" value="57">
<img src="/upload/tech/20091012/20091012013436_98b297950041a42470269d56260243a1.gif" width="32" height="32">
<input type="radio" name="face" value="58">
<img src="/upload/tech/20091012/20091012013436_c9e1074f5b3f9fc8ea15d152add07294.gif" width="32" height="32">
<input type="radio" name="face" value="59">
<img src="/upload/tech/20091012/20091012013437_788d986905533aba051261497ecffcbb.gif" width="32" height="32">
<input type="radio" name="face" value="60">
<img src="/upload/tech/20091012/20091012013437_ef575e8837d065a1683c022d2077d342.gif" width="32" height="32">
<input type="radio" name="face" value="61">
<img src="/upload/tech/20091012/20091012013438_4c56ff4ce4aaf9573aa5dff913df997a.gif" width="32" height="32">
<input type="radio" name="face" value="62">
<img src="/upload/tech/20091012/20091012013438_63dc7ed1010d3c3b8269faf0ba7491d4.gif" width="32" height="32">
<input type="radio" name="face" value="63">
<img src="/upload/tech/20091012/20091012013441_b6edc1cd1f36e45daf6d7824d7bb2283.gif" width="32" height="32">
<input type="radio" name="face" value="64">
</td>
</tr>
<tr>
<td width="54%">名字
<input type="text" name="name">
<br>
Email
<input type="text" name="email">
<br>
标题
<input type="text" name="top" size="50">
<br>
内容<br>
<textarea name="content" cols="50" rows="20"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="submit" value="确定">
<input type="reset" name="cancel" value="重写">
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<p><a href="main.php?user=<? echo $user?>" class="white12"><br>
</a></p>
</BODY>
</HTML>
delnote.php
<?php
include ("config.php");
if ($superadmin){ //如果已经进行管理员登陆,进行密码验证
if (!($user==$username)||!($psw==$password)){
echo "密码错误";
exit;
}
}else{ //管理员登陆
echo "<form name='form1' method='post' action='$PHP_SELF'>";
echo "<div align='center'> 请输入管理员密码<br>";
echo "管理员";
echo "<input type='text' name='user'><br>";
echo "密码";
echo "<input type='password' name='psw'><br>";
echo "<input type='submit' name='superadmin' value='进入'><br>";
echo "<input type='reset' name='cancel' value='重写'></div>";
echo "</form>";
exit;
}
if($del==1){ //判断是否要删除
mysql_query("delete from notebook where time='$time'",$db); //以留言时间为删除标志
echo "删除成功!";
}
?>
<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
$result = mysql_query("SELECT * FROM notebook ",$db);
$row=mysql_num_rows($result);//查看结果有多少行
$max=$row; //帖子总数
//设每页显示10篇,$p总页数,$page第几页,$low 从第几行开始读,$x 读取几行
if (!$page){$page=1;}
$p=ceil($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="/upload/tech/20091012/20091012013351_109a0ca3bc27f3e96597370d5c8cf03d.gif" width="243" height="60" alt="医学导航网" border="0"></a></td>
<td height="62" width="66%">
<div align="center"><img src="/upload/tech/20091012/20091012013351_e94550c93cd70fe748e6982b3439ad3b.gif" width="410" height="60"><img src="/upload/tech/20091012/20091012013352_35f4a8d465e6e1edc05f3d8ab658c551.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">
<table width="95%" border="0" cellspacing="0" cellpadding="0" height="32" bgcolor="#3366FF">
<tr>
<td width="28%" class="white12">首页
> <a href="index.php" class="white12">留言簿</a></td>
<td width="56%" class="white12">
<?php
echo "帖子总数: ",$max," 第";
for ($n=1;$n<=$p;$n++){
echo "<a href=index.php?page=$n>$n</a> ";
}
echo "页";
?>
</td>
<td width="16%"><a href="index.php" class="white12">查看留言</a></td>
</tr>
</table>
<?php
for ($i=0;$i<=($x-1);$i++) {
$email=mysql_result($result,$i,'email');
$face=mysql_result($result,$i,'face');
$face='image/face/icon'.$face;
$name=mysql_result($result,$i,'name');
$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='/upload/tech/20091012/20091012013443_335f5352088d7d9bf74191e006d8e24c.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='/upload/tech/20091012/20091012013443_1385974ed5904a438616ff7bdb3f7439.gif' width='16' height='16' border=0></a></td>";
echo "<td width='21%' height='33' class='blue9'><img src='/upload/tech/20091012/20091012013443_48aedb8880cab8c45637abc7493ecddd.gif' width='13' height='15'> $ip <a href='$PHP_SELF?del=1&time=$time&superadmin=$superadmin&user=$user&psw=$psw'><img src='/upload/tech/20091012/20091012013444_019d385eb67632a7e958e23f24bd07d7.gif' width='16' height='16' border=0></a></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>