上一次我们研究了guest.php文件.具体的问题还要求读者朋友自己深入的去实践,而且需要一些工具书来学习,如果您一点php的知识都没有,笔者奉劝您就不要想下看了,笔者没有太多的时间和篇幅去逐句探究一个php文件的用途和意义.好的,接下来我们来作edit.php这个文件.
———–
//edit.php
<?
if ($submit)
{
if ($savepassword==”on”)
{tcookie(“txtpassword”,”$txtpassword”,time()+30*24*3600);}
el
{tcookie(“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; chart=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]);
}
fclo($fp);
}
$content=file($guestfile,”r”);
$message=$content[$record-1];
$long=st恋爱课rlen($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;
}el {$errorm=”留言人姓名和内容必填!!”;}
}
el {$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>仰望星空与脚踏实地221;;
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″ bgco水产养殖专业lor=”#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代码中,这样写起代码很惬意.
待续…
本文发布于:2023-04-06 05:31:59,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/4bf740895cafdcbccd0e49d0ff47d32b.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:一个php作的文本留言本的例子(二).doc
本文 PDF 下载地址:一个php作的文本留言本的例子(二).pdf
留言与评论(共有 0 条评论) |