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

这一节我们将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)
{

}
?>
<body bgcolor="#FFFFFF" background="back.gif">
----------
注意sys.php中的" $managepwd='zihanonline' "一栏中等号后的是留言本的管理密码号,此时是默认的zihanonline.您可以修改为自己的号码.
未完待续...

(0)

相关推荐

  • 一个php作的文本留言本的例子(三)

    上两节我针对guest.php和edit.php作了讲述.需要注意的是php和html的区别: php通常是-->(1)<? echo("zihanonline");?>             (2)<? php                   echo("zihanonline");                ?>             (3)<script laanguage="php">

  • flash+php+mysql打造简单留言本教程第1/3页

    (主要参考了火山的帖子:★FLASH与ASP通信入门教程--做真正属于自己的留言本!).网上没有比较好的php留言本相关教程,我下载的N多源文件都看得云里雾里,而且好多都将代码写在MC上.又或许可能有好的教程我没搜到,但无论如何,我现在要在这里班门弄斧一番了. flash+php+mysql简单留言本教程 目的: 用flash+php+mysql制作一个简单的留言本. 配置环境: 最开始肯定是先配置相应的环境了.我下载的是配置环境套件包,傻瓜式的方法,简易安装,比较适合我.下载地址:http:/

  • php mysql 留言本应用实例第1/2页

    复制代码 代码如下: <?php $hostname_conn = "localhost"; $database_conn = "test"; $username_conn = "root"; $password_conn = "1981427"; $conn = mysql_connect($hostname_conn, $username_conn, $password_conn); ?> 复制代码 代码如下:

  • 一个php作的文本留言本的例子(六)

    这一节我将为大家讲述关于guest.txt的建立方法和上传的有关事项. ------- //guest.txt <tr><td><font color=#AB00E1>留言内容:</font><br><!--content>zihanonline<!--endcontent> <br><font color=#6633FF>留言人大名:</font><!--name>ziha

  • 一个php作的文本留言本的例子(五)

    现在我们来讲一下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])

  • 我用php+mysql写的留言本

    guestbook.php: <head> <meta http-equiv="Content-Language" content="zh-cn"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title></title> <STYLE>A:link {    

  • 解析PHP留言本模块主要功能的函数说明(代码可实现)

    一,敏感词处理1,过滤敏感词preg_match()函数用来在字符串中搜索所有与给定的正则表达式匹配的内容,如果存在则返回True,否则返回False.语法:int preg_match(string pattern,string subject[,array matches[,int flags]])preg_match()函数参数说明如下:pattern:必要参数,需要匹配的正则表达式subject:必要参数,输入的字符串matches:可选参数.输出搜索结果的数组,例如$out[0]将包含

  • 一个php作的文本留言本的例子(二)

    上一次我们研究了guest.php文件.具体的问题还要求读者朋友自己深入的去实践,而且需要一些工具书来学习,如果您一点php的知识都没有,笔者奉劝您就不要想下看了,笔者没有太多的时间和篇幅去逐句探究一个php文件的用途和意义.好的,接下来我们来作edit.php这个文件. ----------- //edit.php <?    if ($Submit)    { if ($SavePassword=="on") {setcookie("TxtPassword"

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

    大家知道,数据库对于网络来说的重要性.由于cgi的复杂,现在asp和php+mysql已经成为主流.几乎所有的个人网页都要用到留言本,可是申请的留言本很不稳定.这为网上的交流带来了诸多不便.所以,希望拥有自己的留言本的朋友越来越多. 但是,免费的个人主页支持asp和php的很少.笔者现在向您推荐奥索网,(http://www.oso.com.cn)支持php.这样您便有了能够拥有自己留言本的基础.现在,我就通过一个文本留言本的例子来讲述php的简单使用. 首先,我们先确定,留言的几个过程:写留言

  • 超级简单的php+mysql留言本源码

    共3个文件 IncDB.php数据库连接 index.php首页 InsetToDB.php数据库操作 数据库lguestbook里面建表 复制代码 代码如下: CREATE TABLE `intd` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) character set utf8 collate utf8_bin NOT NULL, `text` text character set utf8 collate utf8

  • php+mysql写的简单留言本实例代码

    guestbook.php:  <head>  <meta http-equiv="Content-Language" c>  <meta http-equiv="Content-Type" c>  <title></title>  <STYLE>A:link {          COLOR: #002878; TEXT-DECORATION: none  }  A:visited {    

  • 简单的PHP留言本实例代码

    config.php 复制代码 代码如下: <?php $conn = @mysql_connect("localhost","root","") or die("数据库连接出错!"); mysql_select_db("gb",$conn); mysql_query("set names 'GBK'"); ?> add.php 复制代码 代码如下: <?php inc

  • PHP+MySQL 制作简单的留言本

    留言显示页面:比上一个例子增加了分页和留言回复的功能 主要代码: install/index.php:程序安装页面 复制代码 代码如下: <?php if($_GET["action"]!=1) { ?> <form method="post" action="index.php?action=1"> <table border="1"> <tr> <td>MySQL

随机推荐