电脑安全

您当前的位置:主页 > 电脑安全 >

php制作留言板二[源码]-网络编程

来源:[db:来源]标题:   留言    编辑:电脑技术全能网 时间:2019-09-22 12:30

原标题:php制作留言板二[源码]-网络编程
   第三步就是php代码处置留言的信息正当性了,<?phprequire_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']);?>最四步就是表现留言了.<?phpinclude("../inc/connect.php");?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无题目文档</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></head><body><table width="95%" border="0" align="center" cellpadding="1" cellspacing="1" style="margin-top:20px; border:1px solid #9abcde;"><tr> <td height="25" 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%">你正在治理留言信息... </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;//统计总页面 $page=isset($_GET['page'])?$_GET['page']:1;//获得以后页面 $start=($page>=1 && $page<=$pagecount)?$start=$pagesize*($page-1):$start=1;//获得超始记载 $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="25" colspan="3" align="left" valign="middle" background="images/main_bg.gif" class="td_heng" style="padding-right:5px;"> &nbsp; <input type="checkbox" name="box_x[]" id="box_x[]" value="<?php echo $rs[0];?>" /> 题目:<?php echo $rs['gx_title']?> 作者:<?php echo $rs['gx_object']?> 电话:<?php echo $rs['gx_tel']?> 时光:<?php echo $rs['gx_time']?> 邮箱:<?php echo $rs['gx_mail']?></td> <tr onMouseOver="this.style.background='#d7ebff'" onMouseOut="this.style.background='#ffffff'"> <td height="27" colspan="2" align="left" valign="middle" class="td_heng" style="padding:15px;"> &nbsp;<?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('确认删除?删除后无奈规复','','');">删除</a></td> </tr> <tr> <td height="32" colspan="3">&nbsp;</td> </tr> <?php } } ?> <tr> <td height="32" 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="全选" /> &nbsp; <input type="button" onclick="all_(false);" name="Submit" value="反选" /> &nbsp; <input type="submit" onclick="javascript:return confirm('确认提示:删除后无奈复原!','','');" value='删除所选项' /></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></html>注:原创文章转载请说明:www.dnjishu.com