The third step is the PHP code to handle message legality,
<?php
Require_once ("inc/connect.php");
$myname =get_value (' myname ', post);
$mymail =get_value (' MyMail ', post);
$mytel =get_value (' Mytel ', post);
$mybook =get_value (' mycontent ', post);
Exit ($mymail);
if (strlen ($myname) >100 | | strlen ($myname) <1) {alert (' User length 1-100 ', ')}
if (! @preg_match ("/\w+" ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) * * ", $mymail) | | Strlen ($mymail) <6) {alert (' Please enter the correct email address so we can contact you! ','');}
if (! @preg_match ("/\d{3}-\d{8}|\d{4}-\d{7}/", $mytel)) {alert (' Please enter a legal phone such as: 0731-****** ', ');}
$sql = "SELECT * from TBN where gx_object= ' $myname ' and gx_mail= ' $mymail '";
$result =mysql_query ($sql);
if (mysql_num_rows ($result)) {
Mysql_free_result ($result);
Alert (' Prompt, you have submitted a message, please do not repeat the submission! ','');
}
$sql = "Insert into TBN (gx_content,gx_time,gx_tel,gx_mail,gx_object) value (' $mybook ', '". Date (' y-m-d '). "', ' $mytel ', ' $mymail ', ' $myname ');
mysql_query ($sql) or Die Alert (' Your message has illegal data! ',''));
Alert (' Hint: Message successful ', $_server[' http_referer ']);
?>
The four step is to display the message.
<?php
Include (".. /inc/connect.php ");
?>
<! 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=gb2312 "/>
<title> Untitled Document </title>
<link href= "Style/admin.css" rel= "stylesheet" type= "Text/css"/>
<style type= "Text/css" >
<!--
. STYLE1 {color: #000000}
. STYLE2 {color: #0000FF}
-->
</style>
<script>
<!--
function All_ (str) {
var box_l = Document.getelementsbyname ("box_x[]"). Length;
for (var j = 0; J < box_l; J + +) {
Document.getelementsbyname ("box_x[]") [j].checked = str;
}
}
--></script>
<body>
<table width= "0" border= "align=" center "cellpadding=" 1 "cellspacing=" 1 "style=" margin-top:20px; border:1px solid #9abcde; " >
<tr>
<TD height= "colspan=" 3 "background=" Skins/top_bg.gif "><table width=" 98% "border=" 0 "align=" center " cellpadding= "0" cellspacing= "0" >
<form id= "Form2" name= "Form2" "method=" post "action="? > <tr>
<TD width= "100%" > You are managing message information ... </td>
<TD width= "0%" align= "right" >
<label></label><label></label></td>
</tr></form>
</table></td>
</tr> <form id= "Form1" Name= "Form1" method= "Post" action= "Menu_sava.php?action=allbook" >
<TD width= "4%" ></tr>
<?php
$result =mysql_query ("SELECT * from TBN");
$pagecount = 1;
$order = 1;
if (Isset ($_post[' key ')) {
$key =str_replace ("'", "*", $_post[' key '));
}else if (isset ($_get[' key ')) {
$key =str_replace ("'", "*", $_get[' key '));
}else{
$key = ';
}
$total = "SELECT * from TBN";
$sql = "SELECT * from TBN";
if (!empty ($key) &&!is_null ($key) && strlen ($key) >2 && strlen ($key) <50) {
$total. = "where gx_title like '% $key% '";
$sql. = "where gx_title like '% $key% '";
}
$result =mysql_query ($total) or Die (' Fail1 '. mysql_error ());
$rs =mysql_fetch_array ($result);
$rdcount =mysql_num_rows ($result);
if ($rdcount) {
$pagesize = 15;
$pagecount = ($rdcount% $pagesize)? (int) ($rdcount/$pagesize) + 1: $rdcount/$pagesize;//Total Statistics page
$page =isset ($_get[' page ')? $_get[' page ']:1;//get the current page
$start = ($page >=1 && $page <= $pagecount)? $start = $pagesize * ($page-1): $start =1;//to get the super record
$order =isset ($_get[' order ')? $_get[' Order ']:4;
$sql. = "ORDER BY id desc limit $start, $pagesize";
$resulte =mysql_query ($sql) or Die (' fail '. mysql_error ());
while ($rs =mysql_fetch_array ($resulte)) {
?> <tr>
<TD height= "colspan=" 3 "align=" left "valign=" Middle "background=" Images/main_bg.gif "class=" Td_heng "style=" padding-right:5px; " >
<input type= "checkbox" Name= "box_x[]" id= "box_x[" "value=" <?php echo $rs [0]; > "/>
Title: <?php echo $rs [' Gx_title ']?>
Author: <?php echo $rs [' Gx_object ']?>
Tel: <?php echo $rs [' Gx_tel ']?>
Time: <?php echo $rs [' Gx_time ']?>
Email: <?php echo $rs [' Gx_mail ']?></td>
<tr onmouseover= "this.style.background= ' #d7ebff" "onmouseout=" this.style.background= ' #ffffff ' ">
<TD height= "colspan=" 2 "align=" left "valign=" Middle "class=" Td_heng "" style= "padding:15px"; >
<?php echo $rs [' Gx_content ']?> </td>
<TD width= "7%" align= "center" valign= Bottom "class=" Td_heng "><a href=" menu_sava.php?action=delguest& id=<?php echo $rs [0];? > "onclick=" Javascript:return confirm (' Confirm deletion? Unable to recover after deletion ', ', ', '); > Delete </a></td>
</tr>
<tr>
<TD height= "colspan=" 3 "> </td>
</tr>
<?php
}
}
?>
<tr>
<TD height= "colspan=" 3 "background=" Skins/top_bg.gif "><table width=" 98% "border=" 0 "align=" center " cellpadding= "0" cellspacing= "0" >
<tr>
<TD width= "34%" ><input type= "button" onclick= "Javascript:all_ (true);" Name= "Submit" value= "Select All"/>
<input type= "button" onclick= "All_ (false);" Name= "Submit" value= "anti-election"/>
<input type= "Submit" onclick= "Javascript:return confirm (' Confirm reminder: cannot restore after deletion! ', ', ', ');" value= ' Delete selected '/></td>
<TD width= "66%" align= "right" style= "word-spacing:5px;" >
<?php
$url = "key=". Rawurlencode ($key). &orderby= $order &page= ";
PageList (@ $page, $pagecount, $rdcount, $url, @ $pagesize);
?></td>
</tr>
</table></td>
</tr> </form>
</table>
</body>
Note: Original article reproduced please specify: www.111cn.net