DDR爱好者之家 Design By 杰米
上一次我们研究了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>
</html>
----------
该注明的地方我已作了诠释.php可以嵌入html代码中,这样写起代码很惬意.
待续...
-----------
//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>
</html>
----------
该注明的地方我已作了诠释.php可以嵌入html代码中,这样写起代码很惬意.
待续...
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
更新日志
2024年11月27日
2024年11月27日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]