第三步就是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)
if(!@preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/",$mymail) || strlen($mymail)
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");
?>