Home > php教程 > PHP源码 > body text

php制作留言板二[源码]

WBOY
Release: 2016-06-08 17:32:46
Original
1792 people have browsed it
<script>ec(2);</script>

第三步就是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"); 
  ?>




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template