关于奇矩互动奇矩互动招贤纳士奇矩互动优质虚拟主机Discuz!商业用户享有本站VIP服务LAMP环境配置手册(CentOS5.1)
发新话题
打印

PHP学习专题--第10期:PHP留言本实例讲解

本主题由 Edwin 于 2008-4-5 18:05 加入精华

PHP学习专题--第10期:PHP留言本实例讲解

网络上随处可见各种各样的留言板,一个网页甚至一条新闻都有一个留言板支持,留言板可以让用户方便地提出意见和建议,以方便管理者和浏览用户的交流。简单的留言板只能让用户发表简单的留言,复杂的留言板可以分各个版块留言讨论,并且可以回复论坛中的内容。PHP作为一个优秀的网络脚本语言,用于编写留言板也是非常强大和方便的。本专题将分别介绍PHP和Access、MySQL以及文件存储等方式是如何实现留言板功能的,从而为读者实现网络留言板提供一个基本的思路和实现实例。

挑战最棒的留言本的源码(一)

此留言本的优点和缺点:
-------------------------------------------------------------------
这可能是最重要的了.哈哈!!!

优点:

该留言本最大的优点是,换行.实现了用户换行,(保持原形,中国人的同学录的换行是安一定字数的,也就是说不管你的换行,统统都他给你换行.这样要是想贴文本图形的话,就存在问题了.)而现在大部分的留言本都没有实现自动换行,也就是说它不管你一句写多少个字符,它都会在一行显示,这样要是有一个留言没换行的话,留言本就会变的很难看,窗口下面的行条就会好长,,破坏了叶面的美观!!!.

到今天为止,我还没发现能同时解决这两个问题的留言,这也是我写这留言本的原因所在.

包括oso的论坛,也是不换行的,不信你去留言试试,写一条很长的不回车的字符,这样它的叶面马上就出现问题了.(我和oso提过这问题,不知道改了没有!)

我写了个computer_message($msg);的函数解决了这问题,可以看config.php文件中的源玛.

还有分页:通过两种方式来察看,一是:往前,往后显示留言,另一种是:安页数显示.

还有现在版主可以方便的通过下面的连接来删除和恢复,当然要输入密码.

缺点:

当然有了,要实事求是,就是页面的美化工作做的还不是很够,虽然觉的很必要,但由于时间的关系总觉的这是外面的东西,可以先拖一下,当然只要有一点HTML知识的都可以很方便的修改.

还有就是未知的BUG了!哈哈!!!


下载点,和样本在http://little.oso.com.cn中可以找到!!!


因为说明档是在linux下写的,所以要用写字板打开readme.txt
不要用记事本,要不然会乱码!!!

下面是配置说明:
--------------------------------------------------------------------
为了配置的方便,重新整理了代码,现在已经把全部的需要设置的参数都放在
config.php文件里了,配置起来应该很简单,里面有详悉的说明.

目标:在十分种内搞定你的留言本!!!

1: 建立一个数据库(要主页提供数据库空间)

一般象oso的有phpMyAdmin开放源玛的前端.创建以来很简单的.

取好名字后,记得把config.php 的$db_name改成这个名字

2: 建立留言表(等下把config.php的$table_name改成这里你起的名字).

结构为:
key_liuyan int(11) auto_increment primary key, //主建,自动增加
nikename varchar(20) null // 昵称
subject varchar(100) null // 留言主题
date_created varchar(19) // 留言时间
ip_address varchar(15) // 留言人的IP地址
message mediumtext null // 留言信息
email_address varchar(50) null // 留言人的e-mail地址
zhuye_address varchar(50) null // 留言人的主页地址
huifu_biaozi int(1) default 0 // 版主回复标志
huifu mediumtext null // 版主回复内容
oicq varchar(20) null // 留言人的OICQ号码

可以用如下的SQL来完成!!!(本人测试通过,记得把yourtable_name改成好记点的,
当然不改也行阿)

create table your_liuyan_table(
key_liuyan int(11) auto_increment primary key,
nikename varchar(20) null,
subject varchar(100) null,
date_created varchar(19) ,
ip_address varchar(15),
message mediumtext null,
email_address varchar(50) null,
zhuye_address varchar(50) null,
huifu_biaozi int(1) default 0 ,
huifu mediumtext null,
oicq varchar(20) null
)

3: 建立控制表同样要把这里起的名字放到config.php的$table_name_control里去)

结构如下:

leibie varchar(20) primary key,
value varchar(20) null

也可以用下面的SQL语句:

create table your_control_table(

leibie varchar(20) primary key,
value varchar(20) null
)

因为这是你的控制表,所以要自己加入控制记录两条;

SQL语句为:

插入删除密码:

insert into your_control_tble(
leibie,
value)
values
(delete,'1332');

插入回复密码:

insert into your_control_tble(
leibie,
value)
values
(huifu,'1332');

这样放进去的密码为:123,用户名为空!

怎么计算密码和插入的值的关系呢?

是这样的,你的密码 ,如123 把三位数上的各位加起来,等于6,然后把6乘以222就是密码值!!!

6*222=1332.

知道了这关系,当然你可以改成其它的密码了.

不过用户名要为空,,,


这实行的简单加密的原理可以参照主页 http://cxg168.126.com 的三位数.


4: 一切完成,然后只要把除了readme.txt外的文件上传就行了.

TOP

挑战最棒的留言本的源码(二)

post.php 文件
复制内容到剪贴板
代码:
<?php
require('config.php');
?>




<?php


$nikename=$arr_request['nikename'];

if (strlen($nikename)==0)
{
echo "<center>";

echo "<h2><font color=red>错误信息!</font></h2>";
echo "对不起,<font color=red>呢称</font>必须填写!!! 请重填!
";
echo "<hr></hr>";
echo "免费留言本由<a href=http://little.oso.com.cn>小熊</a>提供技术支持";
echo "</center>";
exit ;

}

$date_now=date('Y/m/d H:i:s');
$ip_address=getenv("REMOTE_ADDR");
$messageold=$arr_request['message'];
//$pattern="/n/";
//$replacement="
";

$message=computer_message($messageold,$hang_zifu_number);

$subjectold=$arr_request['subject'];
if (strlen($subjectold)>$hang_zifu_number)

$subject=computer_message($subjectold,$hang_zifu_number);
else
$subject=$subjectold;

$str_sql=" insert into $table_name
(nikename,subject,date_created,ip_address,message,email_address,zhuye_address,oicq)
values
( '$nikename',
'$subject',
'$date_now',
'$ip_address',
'$message',
'".$arr_request['email_address']."',
'".$arr_request['zhuye_address']."',
'".$arr_request['oicq']."'

)";

$result=mysql_db_query($db_name,$str_sql,$id_link);

if (! $result){
affy_error_exit('SQL Insert Execution has failed.');
}

else

{


echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">";
echo "<HTML><HEAD><TITLE>发表文章</TITLE>";
echo "<META content="text/html; charset=gb2312" http-equiv=Content-Type>";
echo "<meta HTTP-EQUIV="REFRESH" CONTENT="2;URL=display.php">";
echo "</head><body topmargin="0">
";
echo "<ul>谢谢你发表留言,将自动显示留言内容";
echo "
";
echo "<a href=display.php>如果你的浏览器没有自动的返回到留言簿首页,?
请点这里返回.";
echo "</a></ul>";


exit;


}
?>
index.html 文件
复制内容到剪贴板
代码:
<html>
<center>

<title>谢谢你的留言!</title>
<h1><font color=blue>我的留言本</font></h1>
<font color=navy>首先感谢你的留言,你的每一句话我都会仔细阅读!!!</font>

<form action="post.php" method="post">
<table>
<tr>
<td><font color=teal>呢称:</font><font color=red>(不能为空)</font></td><td>
<input type="text" name="nikename" value=""></td>
</tr>


<tr>
<td>OICQ号码:</td><td>

<input type="text" name="oicq" value=""></td>
</tr>
<tr>
<td>e-mail: </td><td>
<input type="text" name="email_address" value="" size="30"></td>
</tr>
<tr>
<td>个人主页:</td><td>
<input type="text" name="zhuye_address" value="http://" size="40"></td>
</tr>
<tr><td>
主题:</td><td>
<input type="text" name="subject" size="40" ></td>
</tr>
<tr><td>
内容:</td><td> </td>
</tr>
<tr><td colspan="2">
<textarea name="message" cols="60" rows="8"></textarea></td>
</tr>
<tr>
<td>
<input type="submit" value="完成留言">
</td>
<td>
<input type="reset" value="重新来过">
</td>
</tr>
</table>
</form>
<p>
<a href=display.php>查看留言</a>
<hr></hr>
免费留言本由<a href="http://little.oso.com.cn" >小熊</a>提供技术支持

</center>

</html>
display.inc文件!!!
复制内容到剪贴板
代码:
<tr bgcolor=>
<td>
<a href=mailto:<?php echo $record->email_address ?> >
<font color="blue" size=4><strong><?php echo $record->nikename ?></strong></font>
</a>
</td>
<td><font color="navy">留言时间:<?php echo $record->date_created ?></font></td>

<td>来自:

<?php
$ip_address=ip_question($record->ip_address);
echo $ip_address;
?>

</td>
</tr>
<tr bgcolor=>
<th colspan=3 align=left>主题:<font color=teal><?php echo $record->subject ?></font></th>

</tr>

<tr><th colspan=3 align=left><font color="#416AAF">
<?php echo $record->message ?></font></th>
</tr>


<?php

if ($record->huifu_biaozi)
{
?>
<tr><th colspan=3 align=left><font color="red">

版主回复:</font><font color="navy">
<?php echo $record->huifu ?></font></th>
</tr>
<?php



}

?>



<tr>
<th colspan=3 align=left>

<a href=mailto:<?php echo $record->email_address ?> >
<img src=image/mail.gif
alt="<?php echo $record->nikename ?>的e-mail地址是:<?php echo $record->email_address ?> "
border="0" width="15" length="15">邮件</a>
<a href=<?php echo $record->zhuye_address ?>><img src=image/home.gif
alt="<?php echo $record->nikename ?>的主页地址是:<?php echo $record->zhuye_address ?> "
border="0"
width="14" length="14" >主页</a>
<img src=image/oicq.gif border="0" alt="<?php echo $record->nikename?>的OICQ是:
<?php echo $record->oicq ?>"
width="14" length="14" >OICQ</a>

<a href=action.php?action=delete&key_liuyan=<?php echo $record->key_liuyan ?>><img src=image/del.gif border="0" width="12" length="12" alt="只有版主才有删除的权限哦!">删除</a>
<a href=action.php?action=huifu&key_liuyan=<?php echo $record->key_liuyan ?> ><img src=image/replay.gif border="0" width="14" length="14" alt="不好意思,现在暂时只有版主才能回复">回复</a>


</th></tr>

<tr>
<td colspan="3"><hr SIZE ="1"></td>
</tr>

TOP

PHP+MYSQL留言本(一)

留言本最基本的功能就是:
  1:用户写留言
  2:把数据写入数据库
  3:显示所有留言


  下面就开始制作我的留言本
  首先在PHPMYADMIN下建立一 guest_book数据库  然后在该数据库下建立一个contents的表  该表下建立两个字段
分别为 name 和 content
  SQL语句如下:
   CREATE TABLE `contents` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(20) NOT NULL default '"no name"',
  `content` mediumtext NOT NULL,
  PRIMARY KEY  (`id`)
  ) TYPE=MyISAM AUTO_INCREMENT=6


好了数据库建好了 ~~`下面开始写程序了
该程序包含三个页面post.htm(留言提交页面) index.php(留言显示页面) updata.php(把数据写入数据库的页面)
post.htm代码如下:
复制内容到剪贴板
代码:
<html>
<head>
<meta http-equiv="Content-Type" c>
<title>留言本</title>
</head>
<body>
   <form action="updata.php" method="post" name="name1">
    姓名:<input type="text" name="user_name">

    留言:<textarea name="post_contents" rows="10" cols="50"></textarea>
    <input type="submit">
   </form>
</body>
</html>
updata.php页面代码如下:
复制内容到剪贴板
代码:
<?
  $name=$_POST['user_name'];
  $content=$_POST['post_contents'];
  $conn=mysql_connect("localhost:6033", "root", "");
   mysql_query("set names utf-8"); //解决中文乱码问题
   mysql_select_db("guest_book");
   $exec="insert into contents (name,content) values ('".$_POST['user_name']."','".$_POST['post_contents']."')";
   $result=mysql_query($exec);
?>
index.php页面代码如下:
复制内容到剪贴板
代码:
<?
$conn=mysql_connect ("localhost:6033", "root", ""); //打开MySQL服务器连接
mysql_select_db("guest_book"); //链接数据库
mysql_query("set names utf-8"); //解决中文乱码问题
$exec="select * from contents"; //sql语句
$result=mysql_query($exec); //执行sql语句,返回结果
while($rs=mysql_fetch_object($result))
{
echo "<table><tr><td>姓名:".$rs->name."</td></tr>";
echo "<tr><td>留言:".$rs->content."</td></tr></table>
";
}?>
至于分页,页面转向等功能暂时不用上去.为得就是使程序尽量精简.麻雀虽小.但是留言本的核心功能全在这里了.
其中还需要再多说几句
$conn=mysql_connect ("localhost:6033", "root", "");
这一句很重要  一开始我用的是 $conn=mysql_connect ("127.0.0.1", "", "");
怎么弄都不见数据进数据库去~~~~但是又没报错~~后来看了半天才知道  原来哪个127的地方应该在PHPMYADMIN里看服务器名一击数据库端口是什么~~~还有ROOT那里就是mysql用户名了,后面的是密码
还有个问题就是 汉字乱码问题
在$result=mysql_query($exec); 语句前面加上mysql_query("set names gb2312");或者mysql_query("set names utf-8");
可疑防止提交进数据库的汉字以乱码形式存放在数据库中 以及防止 从数据库中查询出来的包含汉字的数据以乱码显示
有时候尽管这样设置了后还是无法正常显示汉字~~~~
我就遇见了这样的情况,由于我是在本地调试的,每次都要把浏览器上的那个字符编码调到utf-8才能正常显示汉字
默认的编码总是ISO-8859-1 于是google了一下`~原来是apache设置不对.于是找到 httpd.conf  设置文件
把 default-character-set=ISO-8859-1 改为 default-character-set=utf-8
然后再 service httpd restart 重启appache  清除所有cookies与历史记录~~~然后问题就解决了

TOP

PHP+MYSQL留言本(二)

今天再稍微改善下加一个管理员管理留言的功能~~~这里最主要要用到
$_SESSION['item'] 这个东东~~`  好了`~`先把昨天的稍微改一下 再把这个功能加进去~~~
  首先我们在首页同时显示留言,以及留言添加框~~这样使留言者方便使用`~`
不说多了`~把代码贴出来再说:
index.php
复制内容到剪贴板
代码:
<html>
<head>
<meta http-equiv="Content-Type" c>
<title>留言本</title>
</head>
<body>
<a href="admin_login.htm" tagert="_blank">留言管理</a>
   
   <?
     $conn=mysql_connect ("localhost:6033", "root", ""); //打开MySQL服务器连接
     mysql_select_db("guest_book"); //链接数据库
     mysql_query("set names GB2312"); //解决中文乱码问题
     $exec="select * from contents"; //sql语句
     $result=mysql_query($exec); //执行sql语句,返回结果
     while($rs=mysql_fetch_object($result))  
    {
      echo "<table><tr><td>姓名:".$rs->name."</td></tr>";
      echo "<tr><td>留言:".$rs->content."</td></tr></table>
";
      echo ".............................................................................................................................";
    }
       mysql_close();
?>




<form action="updata.php" method="post" name="name1">
    姓名:<input type="text" name="user_name">

    留言:<textarea name="post_contents" rows="10" cols="50"></textarea>
    <input type="submit" value="提交留言">
   </form>
</body>
</html>
updata.php页再加个header("location:index.php");语句重定向到主页面`~~
updata.php
复制内容到剪贴板
代码:
<?
  $name=$_POST['user_name'];
  $content=$_POST['post_contents'];
  $conn=mysql_connect("localhost:6033", "root", "");
   mysql_query("set names GB2312"); //解决中文乱码问题
   mysql_select_db("guest_book");
   $exec="insert into contents (name,content) values ('".$_POST['user_name']."','".$_POST['post_contents']."')";
   $result=mysql_query($exec);
   mysql_close();
   header("location:index.php");
?>
HOHO~~~是不是用起来有那么回事了`~~
好的`~下面再加个管理功能 ~~那么这个留言本就更加强大了`~
留言管理模块 分为 管理员登录页admin_login.htm ,管理员验证页admin_check.php  后台管理首页admin_index.php
先农这个登录页面admin_login.htm
<form action="admin_check.php" method="post" name="form2">
   用户名:<input type="text" name="admin_name">
   密  码:<input type="password" name="admin_password">
  <input type="submit" value="进入后台管理">
</form>
这个简单得再简单不过了,我就不说什么了`~~
admin_check.php管理员验证
复制内容到剪贴板
代码:
<?
  session_start();
  $admin_name=$_POST['admin_name'];
  $admin_password=$_POST['admin_password'];
  $conn=mysql_connect ("localhost:6033", "root", "");
  mysql_select_db("guest_book");
  $exec="select * from admin where admin_name='".$admin_name."'";
  $result=mysql_query($exec);
   if ($rs=mysql_fetch_object($result))
    { if ($rs->admin_password==$admin_password)
       {$_SESSION['admin']="OK";
        header("location:admin_index.php");
        }
      else echo"密码不正确";
    }
   else echo"用户名不正确";
   
   mysql_close();
?>
这里最主要的就是session~~~凡事要用到session的地方.在页面最开始处要加上这一句session_start();否则就无法使用~~那么session究竟是什么东东呢?由于网页的传输方式(也就是http这个东西) 不是永久连接的~~`所以服务器无法在两个不同页面之间传送变量`~~唉.我一下子也说不清楚`~~还是看看这里http://www.chinalinuxpub.com/read.php?wid=87
上面有很详细的介绍.反正就是用这个东西来验证管理员的身分了`~~
好了下面说后台管理主页面admin_index.php
复制内容到剪贴板
代码:
<?
session_start();
if($_SESSION['admin']=="OK")
{
  $conn=mysql_connect ("localhost:6033", "root", "");
  mysql_select_db("guest_book");
  $exec="select * from contents";
  $result=mysql_query($exec);
  while($rs=mysql_fetch_object($result))
     {
      echo "<table><tr><td>姓名:".$rs->name."</td></tr>";
      echo "<tr><td>留言:".$rs->content."</td></tr></table>
";
      echo  "<a href=modify.php?id=".$rs->id." >修改</a>      <a href=delete.php?id=".$rs->id." >删除</a>";
     }
echo "




<a href=index.php >回首页</a>";
}
mysql_close();
?>
这里最主要是这一句echo  "<a href=modify.php?id=".$rs->id." >修改</a>      <a href=delete.php?id=".$rs->id." >删除</a>";
用来向所连接到的地址传递参数~~看看下面的就知道有什么用了
modify.php
复制内容到剪贴板
代码:
<?
session_start();
if($_SESSION['admin']=="OK")
{
  $conn=mysql_connect ("localhost:6033", "root", "");
  mysql_select_db("guest_book");
  $exec="select * from contents where id=".$_GET['id'];  /*这里这个$_GET['id']就是取得从那个连接传递过来的参数拉 */
  $result=mysql_query($exec);
  $rs=mysql_fetch_object($result);
  $name=$rs->name;
  $content=$rs->content;
  $id=$rs->id;
?>
  <form action="modify2.php" method="post" name="name1">
    ID  :<?=$id?><input type=hidden name=id value=<?=$id?> >
    姓名:<?=$name?>

    留言:<textarea name="post_contents" rows="10" cols="50"><?=$content?></textarea>
    <input type="submit" value="提交修改">
   </form>
<?
  }
mysql_close();
?>
这里这个<?=$id> 其实就等于 echo $id
再看看最终的数据修改实现页面modify2.php
复制内容到剪贴板
代码:
<?
session_start();
if($_SESSION['admin']=="OK")
{
  $conn=mysql_connect ("localhost:6033", "root", "");
  mysql_select_db("guest_book");
  $exec="select * from contents where id=".$_GET['id'];
  $exec="update contents set content='".$_POST['post_contents']."' where id=".$_POST['id'];
  $result=mysql_query($exec);
  
}
mysql_close();
header("location:admin_index.php");
?>
最后就是删除功能的实现了
复制内容到剪贴板
代码:
delete.php
<?
session_start();
if($_SESSION['admin']=="OK")
{
  $conn=mysql_connect ("localhost:6033", "root", "");
  mysql_select_db("guest_book");
  $exec="delete from contents where id=".$_GET['id'];
  mysql_query($exec);
  mysql_close();
header("location:admin_index.php");
}
?>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
今天用到的知识如下:
1: session_start();  $_SESSION['变量名']=$变量名 或者 某一特定值
2: <a href="#####.php?var=##">aaa</a>用这个方法来传递参数  同时用 $_GET['var']来接收传递过来的值
3: 数据修改 :  $exec="update tablename set item1='".$_POST['item1']."' where ...";
4: 数据删除 :  $exec="delete from tablename where...";

TOP

PHP+TEXT留言本(一)

大家知道,数据库对于网络来说的重要性.由于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>
<!--content>$message<!--endcontent> ";
$guestcontent=$guestcontent."
<font color=#6633FF>留言人大名:</font><!--name>$name<!--endname> ";
if ($email !="")
{$guestcontent=$guestcontent."
<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."
<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">

            <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 "
<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>
  

<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>

TOP

PHP+TEXT留言本(二)

上一次我们研究了guest.php文件.具体的问题还要求读者朋友自己深入的去实践,而且需要一些工具书来学习,如果您一点php的知识都没有,笔者奉劝您就不要想下看了,笔者没有太多的时间和篇幅去逐句探究一个php文件的用途和意义.好的,接下来我们来作edit.php这个文件.
-----------
//edit.php
复制内容到剪贴板
代码:
<?
   if ($Submit)
   {
if ($SavePassword=="on")
{setcookie("TxtPassword","$TxtPassword",time()+30*24*3600);}
else
{setcookie("TxtPassword");}
   }
?>
<html>
<style type=text/css>
Td {FONT-SIZE: 10pt;}
TEXTAREA
{
FONT-FAMILY: "宋体";
FONT-SIZE: 10pt;
}

</style>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改留言</title>
<?
require("sys.php");
function readvalue($tags,$tage)
{
global $message,$long,$reply;
$StrStart=strlen(strstr($message,$tags))-strlen($tags);//去除标记后变量所在字串的起始位置.
$StrEnd=strlen(strstr($message,$tage));
$len=$StrStart-$StrEnd;
$StrStart=$long-$StrStart;//起始字符.
$StrString=substr($message,$StrStart,$len);
return $StrString;
}

function save($record)
{
global $TxtContent,$TxtEmail,$TxtHomepage,$TxtEmail,$TxtName,$TxtFrom,$TxtReply,$REMOTE_ADDR,$guestfile;
$content=file($guestfile,"r");
$space = "&nbsp;";
$time = date(Y年m月d日H小时i分);
$ip=$REMOTE_ADDR;
$TxtReply=StripSlashes($TxtReply);
$TxtContent=StripSlashes($TxtContent);
$TxtContent=htmlspecialchars($TxtContent);
$TxtContent=check_strlen_long($TxtContent);
$TxtContent=nl2br($TxtContent);
$Wcontent = "<tr><td><font color=#AB00E1>留言内容:</font>
<!--content>$TxtContent<!--endcontent> ";
$Wcontent=$Wcontent."
<font color=#6633FF>留言人大名:</font><!--name>$TxtName<!--endname> ";
if ($TxtEmail !="")
{$Wcontent=$Wcontent."
<font color=#9900CC>电子信箱</font><a href="mailto:$TxtEmail"><!--email>$TxtEmail<!--endemail></a>"."$space";}
if ($TxtHomepage !="http://")
{$Wcontent=$Wcontent."<font color=#9900CC>主页:</font>$TxtHompage<a href="$TxtHomepage" target=new><!--homepage>$TxtHomepage<!--endhomepage></a>";}
$Wcontent=$Wcontent."
<font color=#0000FF>时间:$time 来自:<!--from>$TxtFrom<!--endfrom> ".$ip."</font>";
$Wcontent=ereg_replace(chr(10),"",$Wcontent);
$Wcontent=$Wcontent."<hr size=1></td></tr>";
$TxtReply=ereg_replace(chr(10),"",$TxtReply);
$WContent=$Wcontent.$TxtReply."n";
$count=count($content);
$fp=fopen($guestfile,"w");
for ($i=0;$i<$count;$i++)
{
if ($i==$record-1)
  {$content[$i]=$WContent;}
fputs($fp,$content[$i]);
}
fclose($fp);
}

$content=file($guestfile,"r");
$message=$content[$record-1];
$long=strlen($message);
$txtcontent=readvalue('<!--content>','<!--endcontent>');
$txtname=readvalue('<!--name>','<!--endname>');
$txtfrom=readvalue('<!--from>','<!--endfrom>');
$txtemail=readvalue('<!--email>','<!--endemail>');
$txthomepage=readvalue('<!--homepage>','<!--endhomepage>');
$txtcontent=strip_tags($txtcontent);
$tags="<!--reply>";
$txtreply=strstr($message,$tags);
$txtreply=ereg_replace(""","&quot;",$txtreply);
if ($Submit)
  {
  if ($TxtPassword==$managepwd)
  {
  if ($TxtName!="" and $TxtContent!="")
    {
  save($record);
  echo "<meta http-equiv=Refresh content="1;url=guest.php">";
  exit;
    }else {$errorm="留言人姓名和内容必填!!";}
  }
  else {$errorm="密码错误,只有管理员有权修改!!";}
  }
?>
</head>

<body bgcolor="#FFFFFF" background="back.gif">
<? include('head.htm');?>
<div align="center">
  <center>
    <table border="1" width="68%" height="31" cellspacing="0" cellpadding="7" bordercolor="#E3E3E3">
     <form action="edit.php" method=post>
     <?
     if ($errorm and $Submit)
     {
        echo"<tr>";  
        echo"<td height=40 colspan=4>";
        echo"<font color=red>出错了,</font>$errorm";
        echo"</td>";
        echo"</tr>";
     }
     ?>
        <tr>  
          <td width="18%" height="37" bgcolor="#f0f0f0"><font color="#000000">留言大名</font></td>
          <td width="39%" height="37" bgcolor="#FFFFFF">  
            <input type="text" name="TxtName" size="26" value=<?echo "$txtname"?>>
             </td>
          <td width="11%" height="37" bgcolor="#f0f0f0"><font color="#000000">来自</font></td>
          <td width="32%" height="37" bgcolor="#FFFFFF">  
            <input type="text" name="TxtFrom" size="20" value=<?echo "$txtfrom"?>>
          </td>
      </tr>
      <tr>  
          <td width="18%" height="31" bgcolor="#f0f0f0"><font color="#000000">主页地址</font></td>
          <td width="39%" height="31" bgcolor="#FFFFFF">  
            <input type="text" name="TxtHomepage" size="26" value=<?echo "$txthomepage"?>>
          </td>
          <td width="11%" height="31" bgcolor="#f0f0f0"><font color="#000000">Email</font></td>
          <td width="32%" height="31" bgcolor="#FFFFFF">  
            <input type="text" name="TxtEmail" size="20" value=<?echo "$txtemail"?>>
          </td>
      </tr>
        <tr bgcolor="#FFFFFF">  
          <td height="31" colspan="4"><font color="#000000">留言内容</font></td>
      </tr>
        <tr bgcolor="#f0f0f0">  
          <td height="105" colspan="4" valign="middle" align="center">  
            <textarea rows="6" name="TxtContent" cols="50" wrap="VIRTUAL"><? echo "$txtcontent"?>
          </textarea>
        </td>
      </tr>
        <tr bgcolor="#FFFFFF">  
          <td height="40" colspan="4" valign="middle" align="center"> <font color="#000000">修改密码</font>  
            <input type="password" name="TxtPassword" size="10" value=<?echo "$TxtPassword"?>>
            <font color="#000000">是否保存密码</font>  
            <input type="checkbox" name="SavePassword" value="on" checked>
          <input type=hidden name=record value=<? echo "$record"?>>
         
          <input type="submit" value="我要修改了" name="Submit">
        </td>
      </tr>
      <? echo "$txtreply"?>
       <input type=hidden name=TxtReply value="<? echo "$txtreply" ?>">
      </form>
    </table>
  </center>
</div>
<?include('bottom.htm');?>
</body>

</html>
----------
该注明的地方我已作了诠释.php可以嵌入html代码中,这样写起代码很惬意.

TOP

PHP+TEXT留言本(三)

上两节我针对guest.php和edit.php作了讲述.需要注意的是php和html的区别:
php通常是-->(1)<? echo("zihanonline");?>
            (2)<? php
                  echo("zihanonline");
               ?>
            (3)<script laanguage="php">
                echo("zihanonline");
               </script>
            (4)<% echo("zihanonline");%>
等4种方式.不要混淆.
下面我们来研究信息管理:manage.php代码.
-----------
//manage.php
复制内容到剪贴板
代码:
<html>

<head>
<title>留言管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<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: 9p}
TH {FONT-SIZE: 9pt}
TD {FONT-SIZE: 9pt}
-->
</style>

</head>

<body bgcolor="#FFFFFF" background="back.gif">
<?
include('head.htm');
include("sys.php");
if ($password!=$managepwd and $dispflag)
  {


  echo "<meta http-equiv=Refresh content=5;url=guest.php>";
  echo "<center>";
  echo "<font color=red>密码错误!无法删除留言!</font>";
  echo "<p>程序将在3秒返回</p>";
  echo "<p> <a href=http://zihanonline.longcity.net>子汉在线</a>斑竹维护管理。</p>";
  echo "
";
  echo "</center>";

  exit;
  }

?>
<table width="445" border="0" align="center" bgcolor="#CCCCCC">
  <form method="post" action="manage.php">
    <?
   if ($dispflag=="show")
   {
  $content = file($guestfile);
  $count =count($content);
  $text="";
     for ($h=$count;$h>0;$h--)
         {
          $text=$text.'<tr><td>删除第'.$h."条留言:<input type=checkbox name=check$h value=$h></td></tr>nn";
          $text=$text.$content[$h-1];
          }
    echo "$text";
    }
  ?>  
    <input type=hidden name=password value=<? echo $password ?>>
    <?
  if ($submit)
  {
  if ($password!=$managepwd)
  {
  echo "<meta http-equiv=Refresh content=5;url=guest.php>";
  echo "<center>";
  echo "<font color=red>密码错误!无法删除留言!</font>";
  echo "<p>程序将在3秒返回</p>";
  echo "<p> <a href=http://zihanonline.longcity.net>子汉在线</a>斑竹维护管理。</p>";
  echo "
";
  echo "</center>";

  exit;
  }
   
  if ($password==$managepwd)
  {
  $guest_content=file($guestfile);
  $count=count($guest_content);
  for ($j=1;$j<=$count;$j++)
   {
   $del_rec_num="check".$j;
   $del_num=$$del_rec_num;
   //echo "$del_num:$del_num";
   $guest_content[$del_num-1]="";
   }

  $fp=fopen($guestfile,"w");
  for ($i=0;$i<=$count-1;$i++)
  {
  if ($guest_content[$i]!="")
   {
   fputs($fp,$guest_content[$i],strlen($guest_content[$i]));
   }
  }
  fclose($fp);
  echo "<meta http-equiv=Refresh content=5;url=guest.php>";
  echo "<center>";
  echo "<p><font color=red>留言已正确删除</font></p>";
  echo "<p>程序将在3秒返回</p>";
  echo "<p> <a href=http://zihanonline.longcity.net>子汉在线</a>斑竹维护管理。</p>";
  echo "
";
  echo "</center>";
  exit;
  }
  }
  ?>  
    <tr>  
      <td bgcolor="#f0f0f0">  
        <p align=center>  
          <input type=submit value=删除 name=submit>
          &nbsp;&nbsp;&nbsp;&nbsp;  
          <input type=reset value=重写 name=reset>
      </td>
    <tr>  
  </form>
</table>
<?include('bottom.htm');?>
</body>
</html>

TOP

PHP+TEXT留言本(四)

这一节我们将dele.php和sys.php放上来.
---------
//dele.php
复制内容到剪贴板
代码:
<html>

<head>
<title>删除留言</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}
-->
</style>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<?

require("sys.php");
if ($Submit)
{

if ($password<>$managepwd)
  {$errorm="<font color=red>密码错误</font>.无权操作..";}

else  
{
$content=file($guestfile);
$message=$content[$record-1];
$count=count($content);
if ($dele=="delreply")
     {
     $replylen=strlen(strstr($message,"<!--reply>"));
     $long=strlen($message);
     $len=$long-$replylen;
     $message=substr($message,0,$len);
     }
     else
     {$message="";}
//writefile
$fp=fopen($guestfile,"w");
for ($i=0;$i<$count;$i++)
  {
  if ($i==($record-1)){$content[$i]=$message;}
  fputs($fp,$content[$i],strlen($content[$i]));
  }//end for
fclose($fp);
echo "<meta http-equiv=Refresh content="1;url=guest.php">";
exit;
}
}// end ifSubmit
$content=file($guestfile);
$message=$content[$record-1];
$found=ereg("<!--reply>",$message);
?>
<body bgcolor="#FFFFFF" background="back.gif">
<? include("head.htm"); ?>
<table width="68%" border="1" cellpadding="5" align="center" cellspacing="0" bordercolor="#F2F2F2">
<form action=dele.php method=post>
<?
  if ($errorm)
  {
echo "<tr>";  
echo "<td height=27>$errorm</td>";
echo "</tr>";
  }
?>
  <? echo $message ?>
    <tr align="center">  
      <td height="37" bgcolor="#f0f0f0">  
        <?
     if ($found)
     {
     echo "<input type=radio name=dele value=delall>";
     echo "全部删除 ";
     echo "<input type=radio name=dele value=delreply checked>";
     echo "仅删除回复";
     }
     ?>
        <font color="#000000">管理密码</font>  
        <input type="password" name="password" size="10">
      <input type=hidden name=record value=<? echo "$record";?>>
        <input type="submit" name="Submit" value="我要删除了">
      </td>
  </tr>
  </form>
</table>
<? include("bottom.htm"); ?>
</body>
</html>

------
//sys.php
<title>zihanonline</title><?


$managepwd='zihanonline';
$guestfile="guest.txt";

function check_strlen_long($txt)
{
  
$count=0;
$arrtemp=$txt;
$len=strlen($txt);
$txt=$txt.'            ';
for ($i=0;$i<$len;$i++)
{
  
if (ord($txt[$i])<128)
  { $count=$count+1;}
  if (ord($txt[$i])==10 or ord($txt[$i])==32)
  {$count=0;}
  if ($count>=70)  
  {
    for ($j=$i;$j<$len;$j++)
    {
    $txt[$j+1]=$arrtemp[$j];
    }
  $txt[$i]="n";
  $len=$len+1;
  $txt[$len]=$arrtemp[$len-1];
  $count=0;
  $arrtemp=$txt;
  }//end if count
}
  $txt=trim($txt);
  return $txt;
}//end function


function encode ($txt)
{
$txt=strip_tags($txt);
$txt=htmlspecialchars($txt);
$message=StripSlashes($txt);
return $message;
}

function ubb($txt)
{

}
?>
----------
注意sys.php中的" $managepwd='zihanonline' "一栏中等号后的是留言本的管理密码号,此时是默认的zihanonline.您可以修改为自己的号码.

TOP

)

PHP+TEXT留言本(五)

现在我们来讲一下reply.php的代码:
---------------------------------
//reply.php
复制内容到剪贴板
代码:
<?


  function check_strlen_long($txt)
{
$len=strlen($txt);
$count=0;
for ($i=0;$i<$len;$i++)
{
if (ord($txt[$i])<128)
  { $count=$count+1;}
  if (ord($txt[$i])==10 or ord($txt[$i])==32)
  {$count=0;}
  if ($count>=60)  
  {
  $txt[$i]="n";
  $count=0;
  }
}
  return $txt;
}

function encode ($txt)
{
$txt=strip_tags($txt);
$txt=htmlspecialchars($txt);
$message=StripSlashes($txt);
return $message;
}

  $content=file("guest.txt");
  $disptext=$content[$record-1];
   
if ($job=="addreply" and $replyname!="" and $replycontent!="")
{
$content=file("guest.txt");
$count=count($content);
$time = date(Y年m月d日H小时i分);
$ip=$REMOTE_ADDR;
$replycontent=StripSlashes($replycontent);
$replyname=encode($replyname);
$replycontent=htmlspecialchars($replycontent);
  $replycontent=check_strlen_long($replycontent);
$replycontent=nl2br($replycontent);
$replycontent=ereg_replace(chr(10),"",$replycontent);
$content[$record-1]=substr($content[$record-1],0,strlen($content[$i])-1); $content[$record-1]=$content[$record-1]."<!--reply><tr><td colspan=4><ul><font color=#AB00E1>回复内容:</font>
".$replycontent."
回复人大名:".$replyname."
<font color=#CC33FF>时间:$time 来自:$ip</font></ul><hr size=1 color=blue></td></tr>n";
$fp=fopen("guest.txt","w");
for ($i=0;$i<$count;$i++)
  {
   fputs($fp,$content[$i],strlen($content[$i]));
  }
  echo "<meta http-equiv=Refresh content=1;url=guest.php>";
  exit;

}
  ?>  
<title>zihanonline</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: 10p}
TH {FONT-SIZE: 10pt}
TD {FONT-SIZE: 10pt}
-->
</style>
<body bgcolor="#FFFFFF" background="back.gif">
<div align=center >
  <? include('head.htm');?>
  <table border= 1  width= 65%  height= 169 cellpadding="8" cellspacing="0" bordercolor="#E3E3E3" >
    <form method= POST  action=reply.php >
      <?
      if ($Submit)
       {
        if ($replyname=="" or $replycontent=="")
        {
      echo"<tr align=left valign=middle bgcolor=#F0F0F0> ";
      echo"<td width= 100%  height= 31 > ";
      echo "<font color=red>出错了</font>回复人姓名和回复内容必填!";
      echo"</td>";
      echo"</tr>";
       }
       }
      ?>
      <? echo $disptext ?>  
      <tr align="left" valign="middle" bgcolor="#F0F0F0">  
        <td width= 100%  height= 31 bgcolor="#FFFFFF" > 回复大名  
          <input type= text  name= replyname  size= 20 >
        </td>
      </tr>
      <tr valign="middle">  
        <td width= 100%  height= 26  align= left bgcolor="#f0f0f0" >  
          <p>回复内容</p>
          </td>
      </tr>
      <tr align="center">  
        <td width= 100%  height= 52  valign= top bgcolor="#FFFFFF" >  
          <textarea rows= 6  name= replycontent  cols= 46 wrap="VIRTUAL" ></textarea>
        </td>
      </tr>
      <tr valign="middle" align="center" bgcolor="#F0F0F0">  
        <td width= 100%  height= 14 bgcolor="#f0f0f0" >  
          <input type=hidden name=job value=addreply>
          <input type=hidden name=record value=<? echo $record ?>>
          <input type= submit  value= 提交  name=Submit >
          &nbsp;&nbsp;&nbsp;  
          <input type=reset value= 重写  name= B2 >
        </td>
      </tr>
    </form>
    </table>   
    <?include('bottom.htm');?>        
</div>
</body>
</html>
------------------


       到此为止,php的代码我们已经写完,剩下的是您要作一个留言本的本头和底部 您可以设计任何的样式.不过记得在本头上面要有至少3个连接:查看 返回主页 发邮件.这样您的留言本系统才算完整.不过由于这是一文本的留言本,所以您不用担心数据库的问题,您只要再写一个guest.txt的文件就完整了.虽然这个留言本没有mysql等等,可是功能仍然不错.而且是完全属于您自己的留言本.好了,下一节我们将为您讲述guest.txt的建立和上传留言本的几个重要步骤.

TOP

PHP+TEXT留言本(六)

这一节我将为大家讲述关于guest.txt的建立方法和上传的有关事项.
-------
//guest.txt
复制内容到剪贴板
代码:
<tr><td><font color=#AB00E1>留言内容:</font>

<!--content>zihanonline<!--endcontent>

<font color=#6633FF>留言人大名:</font>
<!--name>zihanonline<!--endname>
<font color=#9900CC>主页:</font><a href="http://xxx.com" target=new>
<!--homepage>http://xxx.com<!--endhomepage></a>

<font color=#0000FF>时间:2001年4月15日14小时06分 来自:<!--from><!--endfrom> xx.x.x.x</font><hr size=1></td></tr>
-------


       上面是一个guest.txt的写入例子,您可以将他们放上去,然后看一看效果,再进行自己个性化的修改.循序渐进的实践是最最重要的.
一切都做好了,剩下的就是上传了.笔者以cuteftp为例,当您将一切都传到您的主页空间后,您需要有一个连接指向guest.php.这样您才可以让主页和留言本结合起来,另外一个最最重要的是,您要将guest.txt文件的属性改为666,这也是曾经折磨了笔者好一段日子的问题.具体做法是:上传了guest.txt后用鼠标右键点击
guest.txt后出现一串菜单选项,选CHMOD项,在manual方框内添入666,点"确定",好了,大功告成.您可以享受拥有自己的留言本的乐趣了.
全文完

TOP

发新话题