国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

一個php作的文本留言本的例子(一)

2024-05-04 23:01:17
字體:
來源:轉載
供稿:網友

最大的網站源碼資源下載站,

大家知道,數據庫對于網絡來說的重要性.由于cgi的復雜,現在asp和php+mysql已經成為主流.幾乎所有的個人網頁都要用到留言本,可是申請的留言本很不穩定.這為網上的交流帶來了諸多不便.所以,希望擁有自己的留言本的朋友越來越多.
但是,免費的個人主頁支持asp和php的很少.筆者現在向您推薦奧索網,(http://www.oso.com.cn)支持php.這樣您便有了能夠擁有自己留言本的基礎.現在,我就通過一個文本留言本的例子來講述php的簡單使用.
首先,我們先確定,留言的幾個過程:寫留言,發送,查看.(搜索)等等.而且對于斑竹來說,管理留言本又是不可或缺的.這樣我們就不妨定位于6個php文件,1個文本文件.6個php文件分別為:guest.php manage.php reply.php sys.php del.php edit.php,1個文本文件為:guest.txt
先來看看guest.php的內容,你當然可以直接將下面的內容放到您的php網頁里,請尊重作者的勞動,謝謝.
----------------------
//guest.php:<?

require("sys.php");
if ($b1)
{
  if   ($message=="" or $name=="")
  {
  $errorm="<font color=red>出錯了!!!</font>姓名和留言內容必填";
  }
  else
{
#寫入數據
$space = "&nbsp;";
$time = date(y年m月d日h小時i分);
$ip=$remote_addr;
$name=encode($name);
$homepage=encode($homepage);
$from=encode($from);
$email=encode($email);
$message=stripslashes($message);
$message=htmlspecialchars($message);
$message=check_strlen_long($message);
$message=nl2br($message);
$guestcontent = "<tr><td><font color=#ab00e1>留言內容:</font><br><!--content>$message<!--endcontent> ";
$guestcontent=$guestcontent."<br><font color=#6633ff>留言人大名:</font><!--name>$name<!--endname> ";
if ($email !="")
{$guestcontent=$guestcontent."<br><font color=#9900cc>電子信箱</font><a href=/"mailto:$email/"><!--email>$email<!--endemail></a>"."$space";}
if ($homepage !="http://")
{$guestcontent=$guestcontent."<font color=#9900cc>主頁:</font>$hompage<a href=/"$homepage/"><!--homepage>$homepage<!--endhomepage></a>";}
$guestcontent=$guestcontent."<br><font color=#0000ff>時間:$time 來自:<!--from>$from<!--endfrom> $ip</font>";
$guestcontent=ereg_replace(chr(10),"",$guestcontent);
$guestcontent=$guestcontent."<hr size=1></td></tr>/n";
$fp=fopen($guestfile,"a");
fputs($fp,$guestcontent);
fclose($fp);
}
}


?>

<html>
<head>
<title>zihanonlinegbook</title>
<style>
<!--
a:link {text-decoration: none ; color:0000ff}
a:visited {text-decoration: none; color:004080}
a:active {text-decoration: none}
a:hover {text-decoration: underline; color:ff0000}
body {font-size:10pt}
th {font-size:10 pt}
td {font-size: 10pt}
textarea
{
font-family: "宋體";
font-size: 10pt;
}

-->
</style>
<body bgcolor=#fffffd background="bg.jpg">
<div align="center">&nbsp;  
  <? include('head.htm');?>
  <table width="68%" border="1" cellpadding="3" cellspacing="0" bordercolor="#e3e3e3">
    <form method="post" action="guest.php">
      <?
      if ($errorm)
      {
      echo "<tr>";
      echo "<td colspan=3 height=32> ";
      echo "$errorm";
      echo "</td>";
      echo "</tr>";
      }
      ?>  
      <tr>  
        <td width="22%" bgcolor="#f0f0f0"><font color="#000000">姓名<font color="#ff0033">(必填)</font></font></td>
        <td colspan="2" width="78%" bgcolor="#f0f0f0"><font color="#00ff00">  
          <input type="text" name="name" size="40">
          </font></td>
      </tr>
      <tr>  
        <td width="22%" height="29">主頁:</td>
        <td colspan="2" height="29" width="78%">  
          <input type="text" name="homepage" size="40" value="http://">
        </td>
      </tr>
      <tr>  
        <td width="22%" height="27" bgcolor="#f0f0f0">來自:</td>
        <td colspan="2" height="27" width="78%" bgcolor="#f0f0f0">  
          <input type="text" name="from" size="40">
        </td>
      </tr>
      <tr>  
        <td width="22%" height="20">email:</td>
        <td colspan="2" height="20" width="78%"><font color="#00ff00">  
          <input type="text" name="email" size="40">
          </font></td>
      </tr>
      <tr>  
        <td colspan="3" valign="middle" align="left">  
          <div align="center"><font color="#000000">請留言</font><font color="#ff0033">(必填)</font><font color="#00ff00"><br>
            <textarea rows="6" name="message" cols="55" wrap="virtual"></textarea>
            </font></div>
        </td>
      </tr>
      <tr bgcolor="#f0f0f0">  
        <td colspan="3" height="24">  
          <div align="center"><font color="#00ff00">  
            <input type="submit" value="發  送" name="b1">
            &nbsp;&nbsp;&nbsp;  
            <input type="reset" value="重 寫" name="b2">
            </font></div>
        </td>
      </tr>
    </form>
  </table>
  <table width="68%" border="1" cellpadding="4" cellspacing="0" bordercolor="#e3e3e3">
    <tr>  
      <td>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
         <form action=manage.php method=post>
          <tr>  
            <td colspan="2">  
              <input type=hidden name=dispflag value=show>
              管理密碼:  
              <input  type=password name=password size=8>
              &nbsp;  
              <input type=submit value="確  定" name="submit">
            </td>
          </tr>
          </form>
        </table>
      </td>
      <td>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <form action=guest.php method=post>
          <tr>  
            <td> 請輸入關鍵字:  
              <input type="text" name="keyword" size="10">
              <input type="submit" name="search" value="搜索留言">
            </td>
          </tr>
          </form>
        </table>
      </td>
    </tr>
  </table>
  <?
  function search($keyword)
  {
  global $content;
  $count=count($content);
  $subscript=0;
  $arrsearch=array();
  for ($i=0;$i<$count;$i++)
   {
   if (ereg($keyword,$content[$i]))  
     {
     $arrsearch[$subscript]=ereg_replace($keyword,"<font color=red>$keyword</font>",$content[$i]);
     $subscript++;
     }
   }
  return $arrsearch;
  }//end function
  $one_page_line=15;
  $content = file($guestfile);
  if (isset($search) and isset($keyword) and $keyword!="")
  {
  $content=search($keyword);
  }
  $count =count($content);
  ?>
  <table width="68%" border="0">
    <tr>
      <td>
     
      <?
      $int_page_count=$count;//總條數;
      $int_page_num=ceil($int_page_count/$one_page_line);//總頁數;
      echo "<font color=#cc33ff>分頁:";
      for ($i=1;$i<=$int_page_num;$i++)
      {
      echo "<a href=guest.php?page=$i>".$i."</a>&nbsp;";
      }
     echo "</font>";
     if (isset($search) and isset($keyword) and $keyword!="")
     {
      echo "<br><center>";
      echo "下面的留言中包含關鍵字<font color=red>$keyword</font>共<font color=red>".$count."</font>條</center>";
     }
      ?>
      </td><td><p align=right>共有<font color=red><?echo "$count"?></font>條</p></td>
    </tr>
  </table>
</div>
  <br>
<table width="68%" border="0" align="center">
<?
      if ($page=="" or !isset($page))
      {$page=1;}
      $text="";
      $begin_line=$int_page_count-($page-1)*$one_page_line;
      if ($begin_line<$one_page_line){$one_page_line=$begin_line;}
      for ($j=$begin_line;$j>($begin_line-$one_page_line);$j--)
      {
          $text=$text."<tr><td align=right colspan=2><a href=reply.php?job=reply&record=".$j.">回復</a>&nbsp;<a href=edit.php?record=".$j.">編輯</a>&nbsp;<a href=dele.php?record=".$j.">刪除</a>&nbsp;第<font color=red>$j</font>條</td></tr>";
          $text.=$content[$j-1];
           
          //數組找下標從0開始.
         }
   
echo "$text";
?>
</table>
<?
include('bottom.htm');
?>
</body>  
</html>
------------------
未完待續...
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东丽区| 巧家县| 赤水市| 西平县| 天峨县| 甘洛县| 灵石县| 胶州市| 宽甸| 普陀区| 鄂托克前旗| 乡城县| 逊克县| 通江县| 云南省| 奎屯市| 沙洋县| 汤原县| 东丽区| 郁南县| 卢龙县| 镇坪县| 会同县| 霍林郭勒市| 偏关县| 洱源县| 浮山县| 赞皇县| 嘉兴市| 麻城市| 利辛县| 南通市| 隆子县| 南投市| 时尚| 沈阳市| 溆浦县| 平果县| 象山县| 佛山市| 彝良县|