Last time we studied guest. PHP file. the specific problem also requires readers and friends to practice it in depth, and requires some tool books to learn. If you have no knowledge of php, I advise you not to read it, I don't have much time and space to explore the usage and significance of a PHP file one by one. okay. Now let's edit. php file.
-----------
// 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> modify 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 located.
$ 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, 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> message content: </font> <br> <! -- Content> $ TxtContent <! -- Endcontent> ";
$ Wcontent = $ Wcontent. "<br> <font color = # 6633FF> name of the speaker: </font> <! -- Name> $ TxtName <! -- Endname> ";
If ($ TxtEmail! = "")
{$ Wcontent = $ Wcontent. "<br> <font color = # 9900CC> email box </font> <a href =" mailto: $ TxtEmail "> <! -- Email> $ TxtEmail <! -- Endemail> </a> "." $ space ";}
If ($ TxtHomepage! = "Http ://")
{$ Wcontent = $ Wcontent. "<font color = # 9900CC> Home Page: </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 (10), "", $ Wcontent );
$ Wcontent = $ Wcontent. "$ 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 = "the contact name and content are required !! ";}
}
Else {$ errorm = "the password is incorrect. Only the Administrator has the right to modify it !! ";}
}
?>
</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> error, </font> $ errorm ";
Echo "</td> ";
Echo "</tr> ";
}
?>
<Tr>
<Td width = "18%" height = "37" bgcolor = "# f0f0f0"> <font color = "#000000"> message name </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"> from </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"> Home address </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"> message content </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"> Change Password </font>
<Input type = "password" name = "TxtPassword" size = "10" value = <? Echo "$ TxtPassword"?>
<Font color = "#000000"> whether to save the 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 modify" name = "Submit">
</Td>
</Tr>
<? Echo "$ txtreply"?>
<Input type = hidden name = TxtReply value = "<? Echo "$ txtreply"?> ">
</Form>
</Table>
</Center>
</Div>
<? Include('bottom.htm');?>
</Body>
</Html>
----------
I have already explained this. php can be embedded in html code, so it is cool to write the code.
To be continued...