支援oicq頭像的留言簿(一)

來源:互聯網
上載者:User
特點:
支援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="http://edu.cnzz.cn/NewsInfo/image/logo.gif" width="243" height="60" alt="醫學導航網" border="0"></a></td>
    <td height="62" width="66%">  
      <div align="center"><img src="http://edu.cnzz.cn/NewsInfo/image/note.gif" width="410" height="60"><img src="http://edu.cnzz.cn/NewsInfo/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="http://edu.cnzz.cn/NewsInfo/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='http://edu.cnzz.cn/NewsInfo/$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://edu.cnzz.cn/NewsInfo/image/email.gif' width='16' height='16' border=0></a></td>";
echo        "<td width='21%' height='33' class='blue9'><img src='http://edu.cnzz.cn/NewsInfo/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> 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.