Okay, now let's look at the program code for the login.php file.
<?php
Session_Start ();
Include ("global.php");
if (isset ($_post[' username ')) && isset ($_post[' pwd '])
{
$result = mysql_query ("SELECT * from Xx_admin");
if ($info = mysql_fetch_array ($result))
{
if ($_post[' username '] = = $info [' username '] && $info [' password '] = = MD5 ($_post[' pwd '])
{
$_session[user] = $info [' username '];
Echo ("Login ok!");
Die ("<script>window.location.href= ' index.php ';</script>");
}
else echo (' <script>window.alert Login failed! '); window.location.href= '. $_server[' php_self '. "'; </script> ");
}
}
?>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Admin Login </title>
<style type= "Text/css" >
<!--
Body {
Background: #EAF4FF;
font-size:12px;
}
-->
</style>
<body>
<table width= "border=" "0" cellspacing= "0" cellpadding= "0" align= "center" >
<form action= "<?php echo $_server[' php_self ';?>" method= "POST" name= "login" id= "Login" >
<tr>
<TD height= "></td>"
<TD height= ><strong> Admin Login </strong></td>
</tr>
<tr>
<TD width= "height=" align= "right" > Username: </td>
<TD width= "181" height= "><label>"
<input name= "username" type= "text" class= "Loginput" id= "username" "value=" "/>"
</label></td>
</tr>
<tr>
<TD height= "align=" "right" > Password: </td>
<TD height= "><label>"
<input name= "pwd" type= "password" class= "Loginput" id= "pwd"/>
</label></td>
</tr>
<tr>
<TD height= "> </td>"
<TD height= "><label>"
<input name= "Submit" type= "submit" class= "Botton" value= "Login"/>
</label></td>
</tr>
</form>
</table>
</body>
After landing will be able to see the message will be used mreplay.php to answer the questions of netizens. The code is as follows.
<?php
Session_Start ();
Include ("global.php");
if (!$_session[user])
Die ("<script>window.alert") (' please log in first! '); window.location.href= ' login.php ';</script> ');
if (Isset ($_get[' act ')) && $_get[' act ']== ' reply ')
{
$content = $_post[' reply '];
$content = Str_replace ("", " ", $content);
$content = Str_replace ("", " ", $content);
$content = Str_replace ("\ n", "<br/>", $content);
$sql = "UPDATE xx_guestbook SET reply = ' {$content} ', Replytime = '". Date (' y-m-d h:i:s '). "' WHERE mid = ". Intval ($_get[' mid ']);
Echo $sql;
$row =mysql_query ($sql);
if ($row)
{
Echo ("Reply ok!");
Die ("<script>window.location.href= ' lyb.php ';</script>");
}
else echo ("false");
}else
if (Isset ($_get[' act ')) && $_get[' act ' = = ' edit ')
{
if (Isset ($_get[' mid '))
{
$mid = Intval ($_get[' mid ']);
$row =mysql_query ("select * from Xx_guestbook WHERE mid = {$mid}");
if ($row)
{
$rs =mysql_fetch_array ($row);
Print_r ($RS); DEBUG
echo "<meta http-equiv=\" refresh\ "content=\" 1; Url=index2.php\ ">";
$reply = $rs [' reply '];
$reply = Str_replace ("<br/>", "\ n", $reply);
$reply = Str_replace (" ", "", $reply);
$reply = Str_replace (" ", "", $content);
$reply = Str_replace ("<br/>", "", $reply);
}
else echo ("false");
}
?>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Editorial Reply Message </title>
<body>
<table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "align=" center ">
<form action= "<?php $_server[' php_self '];? >?act=reply&mid=<?php Echo (" {$rs [' Mid ']} ");? > "method=" Post "name=" id= "message" >
<tr>
<TD height= align= "center" ><strong> reply message <?php echo $_get[' mid ';?></strong></td>
</tr>
<tr>
<TD height= "align=" "Center" ><label>
<textarea name= "Reply" cols= "" rows= "" class= "input" id= "reply" ><?php echo $reply?></textarea>
</label></td>
</tr>
<tr>
<TD height= "align=" "Center" ><label>
<input name= "Submit" type= "submit" class= "Botton" value= "reply message"/>
</label></td>
</tr>
</form>
</table>
</body>
<?php
}
?>