澳门皇冠金沙网站-澳门皇冠844网站

热门关键词: 澳门皇冠金沙网站,澳门皇冠844网站

一个php作的文本留言本的例子,一个没有MYSQL数据

鉴于国内MySQL财富相比较恐慌,国外的不是太慢,正是不对作者国用户开放。因而,在尚未MYSQL的光阴里,大家想做一些方便客人和完美本身站点的事情,那几乎比登天还难,为了摆脱这种伤痛,niky哭思冥想,闭门造车,终于,只要武术深铁杵磨成针,八个无需MYSQL数据库补助的简要留言本就这样出台了,大家暂时叫它gbook.php吧,源程序如下:

大家了然,数据库对于互连网来讲的要紧性.由于cgi的眼花缭乱,未来asp和php mysql已经济体改为主流.差不离全数的村办网页都要用到留言本,但是申请的留言本很不牢固.那为英特网的交流带来了繁多不便.所以,希望保有自个儿的留言本的爱侣更多.
不过,无需付费的个人主页帮衬asp和php的非常少.作者今后向您推荐奥索网,(.
率先,大家先鲜明,留言的多少个进度:写留言,发送,查看.(找寻)等等.并且对于斑竹来讲,管理留言本又是不可缺少的.那样我们就无妨定位于6个php文件,1个公文文件.6个php文件分别为:guest.php manage.php reply.php sys.php del.php edit.php,1个文件文件为:guest.txt

上叁遍大家探讨了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 = " ";
$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><br><!--content>$TxtContent<!--endcontent> ";
$Wcontent=$Wcontent."<br><font color=#6633FF>留言人民代表大会名:</font><!--name>$TxtName<!--endname> ";
if ($TxtEmail !="")
{$Wcontent=$Wcontent."<br><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."<br><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(""",""",$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>

<?
if ($message)
    {
    $message = ereg_replace( "rnrn",  "n<P>", $message);
//去除无效的调整符号
    $date = date( "l, F j Y, h:i a"); //获取钦赐的日期时间格式
    $ip=getenv("REMOTE_ADDR");
    $message =  "<table border="0" cellspacing="0" width="640" cellpadding="0">
  <tr>
    <td width="25%"><B>$name </B></td>
    <td width="25%">$email</td>
    <td width="25%">写于--$date</td>
    <td width="25%">来自>>$ip</td>
  </tr>
  <tr>
    <td width="100%" colspan="4">$subject</td>
  </tr>
  <tr>
    <td width="100%" colspan="4">$massage</td>
  </tr>
</table><hr>       

先来看看guest.php的内容,你当然能够直接将上面包车型地铁剧情放到您的php网页里,请尊重小编的劳顿,多谢.

//guest.php:<?

require("sys.php");
if ($B1)
{
  if   ($message=="" or $name=="")
  {
  $errorm="<font color=red>出错了!!!</font>姓名和留言内容必填";
  }
  else
{
#写入数据
$space = " ";
$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">   
  <? 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=";
        </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">
                 
            <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>
                 
              <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> ";
      }
     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> <a href=edit.php?record=".$j.">编辑</a> <a href=dele.php?record=".$j.">删除</a> 第<font color=red>$j</font>条</td></tr>";
          $text.=$content[$j-1];

          //数组找下标从0发轫.
         }

echo "$text";
?>
</table>
<?
include('bottom.htm');
?>
</body>  

</html>

该证明的地点作者已作了疏解.php能够停放html代码中,那样写起代码很安适.
待续...

本文由澳门皇冠金沙网站发布于编辑程序,转载请注明出处:一个php作的文本留言本的例子,一个没有MYSQL数据