免费邮箱 |加入收藏 | 会员中心 | 我要投稿 | RSS
您当前的位置:首页 > PHP专区 > PHP实例

PHP+TEXT留言本(一)

时间:2011-05-21 09:29:16  来源:站内  作者:潘春会

大家知道,数据库对于网络来说的重要性.由于cgi的复杂,现在asp和php+MySQL已经成为主流.几乎所有的个人网页都要用到留言本,可是申请的留言本很不稳定.这为网上的交流带来了诸多不便.所以,希望拥有自己的留言本的朋友越来越多.
但是,免费的个人主页支持asp和php的很少.笔者现在向您推荐动站指南,(http://www.knowsky.com)支持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">

来顶一下
返回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
如何找出DHCP地址池里未使用的IP地址
如何找出DHCP地址池里
国内常用的DNS列表
国内常用的DNS列表
Linux邮件服务器软件比较
Linux邮件服务器软件比
学用纯CSS打造可折叠树状菜单
学用纯CSS打造可折叠树
相关文章
栏目更新
栏目热门