第三步就是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('用户长度1-100','');}
if(!@preg_match("/w ([- .]w )*@w ([-.]w )*.w ([-.]w )*/",$mymail) || strlen($mymail)<6 ){alert('请输入正确的邮箱地址以便我们与你联系!','');}
if(!@preg_match("/d{3}-d{8}|d{4}-d{7}/",$mytel)){alert('请输入合法的电话如: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('提示,你己提交留言,请不要重复提交!','');
}
$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('你的留言中有非法数据!',''));
alert('提示:留言成功',$_SERVER['HTTP_REFERER']);
?>
最四步就是显示留言了.
include("../inc/connect.php");
?>
<script><br>
<!--<br />
function all_(str){</p>
<p><br />
var box_l = document.getElementsByName("box_x[]").length;</p>
<p><br />
for(var j = 0 ; j < box_l ; j ){</p>
<p><br />
document.getElementsByName("box_x[]")[j].checked = str;</p>
<p><br />
}</p>
<p><br />
}<br />
--></script>
<表格宽度=“95%”边框=“0”对齐=“中心”cellpadding=“1”cellspacing=“1”样式=“margin-top:20px;边框:1px实体#9abcde;”>