Example of a text message in PHP (ii)

Source: Internet
Author: User
Tags chr include modify php file require setcookie strlen
The last time we studied the guest.php file. The specific problems also require readers to practice their own in-depth, but also need some reference books to learn, if you do not have a little knowledge of PHP, I advise you do not want to look down, The author does not have much time and space to step into the purpose and meaning of a php file. Ok, let's do edit.php this file.
-----------
edit.php

?
if ($Submit)
{
if ($SavePassword = = "on")
{Setcookie ("Txtpassword", "$TxtPassword", Time () +30*24*3600);}
Else
{Setcookie ("Txtpassword");}
}
?>
<style type=text/css>
Td {font-size:10pt;}
TEXTAREA
{
Font-family: "The song Body";
font-size:10pt;
}

</style>
<meta http-equiv= "Content-language" content= "ZH-CN" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Change Message </title>
?
Require ("sys.php");
function ReadValue ($tags, $tage)
{
Global $message, $long, $reply;
$StrStart =strlen (Strstr ($message, $tags))-strlen ($tags);//Remove the starting position of the string where the variable is marked.
$StrEnd =strlen (Strstr ($message, $tage));
$len = $StrStart-$StrEnd;
$StrStart = $long-$StrStart;//start character.
$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-year m-month D-day H I-hour);
$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 > Message content:</font><br><!--content>$ txtcontent<!--endcontent> ";
$Wcontent = $Wcontent. " <br><font color= #6633FF > Message:</font><!--name> $TxtName <!--endname> ";
if ($TxtEmail!= "")
{$Wcontent = $Wcontent. " <br><font color= #9900CC > Email </font><a href= "mailto: $TxtEmail" ><!--email> $TxtEmail <!--endemail></a> "." $space ";}
if ($TxtHomepage!= "http://")
{$Wcontent = $Wcontent. " <font color= #9900CC > Home:</font> $TxtHompage <a href= "$TxtHomepage" target=new><!--homepage>$ txthomepage<!--endhomepage></a> ";}
$Wcontent = $Wcontent. " <br><font color= #0000FF > Time: $time from:<!--from> $TxtFrom <!--endfrom> ". $ip." </font> ";
$Wcontent =ereg_replace (CHR), "", $Wcontent);
$Wcontent = $Wcontent. " $TxtReply =ereg_replace (CHR), "", $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 = "message person name and content must be filled!!";}
}
else {$errorm = "Password error, only administrator has permission to modify!!";}
}
?>

<body bgcolor= "#FFFFFF" background= "Back.gif" >
? Include (' head.htm ');? >
<div align= "center" >
<center>
<table border= "1" width= "68%" height= "to" 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> error,</font> $errorm";
echo "</td>";
echo "</tr>";
}
?>
<tr>
&LT;TD width= "18%" height= "Panax Notoginseng" bgcolor= "#f0f0f0" ><font color= "#000000" > Message name </font></td>
&LT;TD width= "39%" height= "Panax Notoginseng" bgcolor= "#FFFFFF" >
<input type= "text" name= "txtname" size= "" Value=<?echo "$txtname"?>>
</td>
&LT;TD width= "11%" height= "Notoginseng" bgcolor= "#f0f0f0" ><font color= "#000000" > from </font></td>
&LT;TD width= "32%" height= "Panax Notoginseng" bgcolor= "#FFFFFF" >
<input type= "text" name= "Txtfrom" size= "" Value=<?echo "$txtfrom"?>>
</td>
</tr>
<tr>
&LT;TD width= "18%" height= "bgcolor=" #f0f0f0 "><font color=" #000000 "> Home address </font></td>
&LT;TD width= "39%" height= "bgcolor=" "#FFFFFF" >
<input type= "text" name= "Txthomepage" size= "" Value=<?echo "$txthomepage"?>>
</td>
&LT;TD width= "11%" height= "bgcolor=" #f0f0f0 "><font color=" #000000 ">Email</font></td>
&LT;TD width= "32%" height= "bgcolor=" "#FFFFFF" >
<input type= "text" name= "Txtemail" size= "" Value=<?echo "$txtemail"?>>
</td>
</tr>
<tr bgcolor= "#FFFFFF" >
&LT;TD height= "colspan=" 4 "><font color=" #000000 "> Message content </font></td>
</tr>
<tr bgcolor= "#f0f0f0" >
&LT;TD height= "colspan=" "4" valign= "Middle" align= "center" >
<textarea rows= "6" name= "Txtcontent" cols= "a" wrap= "VIRTUAL" &GT;&LT;? echo "$txtcontent"?>
</textarea>
</td>
</tr>
<tr bgcolor= "#FFFFFF" >
&LT;TD height= "colspan=" 4 "valign=" Middle "align=" center "> <font color=" #000000 "> Modify password </font>
<input type= "Password" name= "Txtpassword" size= "ten" Value=<?echo "$TxtPassword"?>>
<font color= "#000000" > whether to save password </font>
<input type= "checkbox" Name= "Savepassword" value= "on" checked>
<input Type=hidden Name=record value=<? echo "$record"?>>

<input type= "Submit" value= "I want to Revise" name= "submit" >
</td>
</tr>
? echo "$txtreply"?>
<input Type=hidden name=txtreply value= " echo "$txtreply"?> ">
</form>
</table>
</center>
</div>
<?include (' bottom.htm ');? >
</body>

----------
I have made an interpretation of the annotated place. PHP can be embedded in the HTML code, so it's nice to write code.
Cond...


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.