威尼斯登录首页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-******','');}

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" ";
<html xmlns=";
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<head>
<style type="text/css教程">
<!--
.menu { color:#000000; font-size: 12px; cursor: hand;}
</style>
<script type="text/网页特效">
function showmenu(menuid)
 {
 if(menuid.style.display=="none")
 {
 menuid.style.display="";
 }
 else
 {
 menuid.style.display="none";
 }
 }
</script>
<title>电视树状目录</title>
</head>
<body>
<?php
 $globals["id"] =1;
 $jibie=1;
 $sql="select * from tvmenu where bid=0";
 $result=mysql教程_query($sql,$conn);
 
 if(mysql_num_rows($result)>0)
 treemenu($conn,$result,$jibie,$id);
 
 function treemenu($conn,$result,$jibie)  //进入函数循环
 {
 $numrows=mysql_num_rows($result);
 echo "<table cellpadding='0' cellspacing='0' border='0'>";
 for($rows=0;$rows<$numrows;$rows++)
 {
 $menu=mysql_fetch_array($result);
 $sql="select * from tvmenu where bid=$menu[id]";
 $result_sub=mysql_query($sql,$conn);
 echo "<tr>";
  //如果该菜单项目有子菜单,则添加javascript onclick语句
  if(mysql_num_rows($result_sub)>0)
  {
  echo "<td width='20'><img src='+.gif' border='0'></td>";
  echo "<td class='menu' onclick='javascript:showmenu(menu".$globals["id"].");'>";
  }
  else
  {
  echo "<td width='20'><img src='-.gif' border='0'></td>";
  echo "<td class='menu'>";
  }
  if($menu[url]!="")
  echo "<a href='$menu[url]'>$menu[name]</a> ";
  else
  echo "<a href='#'>$menu[name]</a>   <a href='?b={$menu[id]}&tpye=add'> 添加</a>  <a href='?b={$menu[id]}&tpye=edit'> 编辑</a>  <a href='?b={$menu[id]}&action=del'> 删除</a>";
  echo "</td> </tr>";
  if(mysql_num_rows($result_sub)>0)
  {
  echo "<tr id=menu".$globals["id"]++." style='display:none'>";
  echo "<td width='20'> </td>";
  echo "<td>";
  //将级数加1
  $jibie++;
  treemenu($conn,$result_sub,$jibie);
  $jibie--;
  echo "</td></tr>";
  }
  //显示下一菜单
  }
  echo "</table>";
}
?>
<br />
<br />
<?php if ($tpye=="add") { ?>
<table width="551" border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc">
<form action="" method="post" name="form1">
  <tr>
    <td height="28" colspan="2" align="center" bgcolor="#ffffff">添加栏目</td>
  </tr>
  <tr>
    <td width="246" height="28" align="right" bgcolor="#ffffff">栏目名称:</td>
    <td width="302" height="28" bgcolor="#ffffff"><input name="name" type="text" id="name" /></td>
  </tr>
  <tr>
    <td height="28" align="right" bgcolor="#ffffff">所属分类:</td>
    <td height="28" bgcolor="#ffffff"><select name="bid">
<?php
   
 $sql="select * from tvmenu";
 $que=mysql_query($sql,$conn);
    while($rs=mysql_fetch_array($que)){
  if ($rs['id']==$b) {
     $selected="selected="selected"";
     }else{
     $selected="";
     }
 ?>
 
      <option value="<?php echo $rs["id"]; ?>" <?php echo $selected;?>><?php echo $rs["name"]; ?></option>
  <?php }?>
    </select>
    </td>
  </tr>
  <tr>
    <td height="28" colspan="2" align="center" bgcolor="#ffffff"><input type="submit" name="submit" value="提 交" /></td>
  </tr>
  </form>
</table>
<?php }?>

$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 xmlns= content=text/html; charset=gb2312 /title无标题文档/titlelink href=style/admin.css rel=stylesheet type=text/css /

 

style type=text/css!--.STYLE1 {color: #000000}.STYLE2 {color: #0000FF}--/stylescript!--function all_(str){

 代码如下

var box_l = document.getElementsByName(box_x[]).length;

<?php if ($tpye=="edit") {

for(var j = 0 ; j box_l ; j++){

 $sql="select * from tvmenu where id='$b'";
 //echo $sql ;
 //exit;
 $quea=mysql_query($sql,$conn);
 $rsa=mysql_fetch_array($quea);

document.getElementsByName(box_x[])[j].checked = str;

 ?>
<table width="551" border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc">
<form action="" method="post" name="form1">
  <tr>
    <td height="28" colspan="2" align="center" bgcolor="#ffffff">编辑栏目</td>
  </tr>
  <tr>
    <td width="246" height="28" align="right" bgcolor="#ffffff">栏目名称:</td>
    <td width="302" height="28" bgcolor="#ffffff"><input name="name" type="text" id="name" value="<?php echo $rsa['name'];?>" /></td>
  </tr>
  <tr>
    <td height="28" align="right" bgcolor="#ffffff">所属分类:</td>
    <td height="28" bgcolor="#ffffff"><select name="bid">
 <?php
   $sql="select * from tvmenu where bid<>'$rsa['bid']'";
     $que=mysql_query($sql,$conn);
           while($rs=mysql_fetch_array($que)){
     if ($rs["id"]==$rsa['bid']) {
     $selected="selected="selected"";
     }else{
     $selected="";
     }
 ?>
 
      <option value="<?php echo $rs["id"]; ?>" <?php echo $selected;?>><?php echo $rs["name"]; ?></option>
  <?php }?>
    </select>
    </select>
    </td>
  </tr>
  <tr>
    <td height="28" colspan="2" align="center" bgcolor="#ffffff"><input type="submit" name="submit" value="提 交" /></td>
  </tr>
  </form>
</table>
<?php }?>

}

<br />
注:"+"为存在子目录,可以展开,"-"为终极分类.
</body>
</html>

}--/script/head

<?php
//php
 $conn=mysql_connect("localhost","root","root");
 mysql_select_db("gztv");  //打开数据库
 mysql_query("set names 'gb2312'"); //避免乱码
 $tpye=trim($_get["tpye"]);
 $action=$_get["action"];
 $id=$_get["id"];
 $b=trim($_get["b"]);
 $name=$_post["name"];
 $bid=$_post["bid"];
 switch ($action) {
 case add:
  $sql="insert into `gztv`.`tvmenu` (`id` ,`bid` ,`name` ,`url` )values (null , '$bid', '$name', null);";
     $qu=mysql_query($sql,$conn);
  if($qu){
  $add="";
  print "<script language='javascript'>alert('添加成功!');window.location='tree.php'</script>";
  exit;
  }
  break;
 case edit:
  $sql="update tvmenu set name='$name', bid='$bid' where id='$id'";
      $qu=mysql_query($sql,$conn);
  if($qu){
  $edit="";
  //header ("location:tree.php");
  echo  "<script language='javascript'>alert('编辑成功!');window.location='tree.php'</script>";
        exit;
  }
  break;
 case del:
  $sql="delete from tvmenu where id='$b'";
    $qu=mysql_query($sql,$conn);
  if($qu){
  $del="";
  echo  "<script language='javascript'>alert('删除成功!');window.location='tree.php'</script>";
  exit;
  }
 }
?>

bodytable 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.giftable 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/labellabel/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%' ;

<?
/*
-- phpmyadmin sql dump
-- version 2.11.4

} $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_henga href=menu_sava.php?action=delguestid=?php echo $rs[0];? onclick=javascript:return confirm('确认删除?删除后无法恢复','','');删除/a/td /tr tr td height=32 colspan=3nbsp;/td /tr ?php } } ? tr td height=32 colspan=3 background=skins/top_bg.giftable 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=$orderpage=; pagelist(@$page,$pagecount,$rdcount,$url,@$pagesize); ?/td /tr /table/td /tr /form/table/body/html

--

-- 主机: localhost
-- 生成日期: 2008 年 10 月 21 日 17:19
-- 服务器版本: 5.0.45
-- php 版本: 5.2.5

set sql_mode="no_auto_value_on_zero";

--

注:原创文章转载请注明:

-- 数据库: `gztv`


--

-- 表的结构 `tvmenu`

create table if not exists `tvmenu` (
  `id` tinyint(4) not null auto_increment,
  `bid` tinyint(4) not null default '0',
  `name` varchar(20) default null,
  `url` varchar(60) default null,
  primary key  (`id`)
) engine=innodb  default charset=utf8 auto_increment=16 ;

--

-- 导出表中的数据 `tvmenu`

insert into `tvmenu` (`id`, `bid`, `name`, `url`) values
(1, 0, '电视1', ''),
(2, 0, '电视2', ''),
(3, 1, '电视3', ''),
(4, 1, '电视4', ''),
(5, 2, '电视5', ''),
(6, 2, '电视6', ''),
(7, 3, '电视7', ''),
(8, 3, '电视8', ''),
(9, 3, '电视9', ''),
(10, 5, '电视10', ''),
(11, 5, '电视11', ''),
(12, 5, '电视12', ''),
(13, 6, '电视13', ''),
(14, 6, '电视1422', '');

*/?>

本文由威尼斯在线注册平台发布于威尼斯登录首页,转载请注明出处:威尼斯登录首页php制作留言板二[源码]

上一篇:威尼斯登录首页for语句能够说是PHP的轮回调节部份最基本的三个语句了 下一篇:没有了
猜你喜欢
热门排行
精彩图文