模块的介绍

来源:互联网 发布:专业电子相册制作软件 编辑:程序博客网 时间:2024/05/17 01:49

 过滤

<?php
include("dbconnect.php");
include("function.php");
//调用check_form函数进行过滤
//将当前页面form表单的input信息进行过滤
//method=post-----$_POST[]
//input 的name属性分别是edit[name] edit[pass] edit[pass2];
//
//$_POST['edit'];
$form =check_form($_POST['edit']);//经过过滤
//将用户传入的数组$form 拆成独立的变量
//插入数据表
//extract();将数组中的元素换成独立的变量,元素下标=元素值
//产生了三个变量$name.$pass $pass2
//变量值为客户端用户输入信息(过滤后的)
$sql="insert into tbl_user values($a,$b)"

 

 

 

 

 

//行成表单POST
//获取表单数据$_POST['input标签的name属性名'] 例如:
//name=edit[username];
//php的安全问题"usern \'\'  '\'  id"
//第一种办法   添加反斜杠函数 过滤  addslashes() 
 //            取消反斜杠      stripslashes()

//第二种方法:php.ini
//要求用户具备编辑主配置文件的权限
//magic_qudtes_gpc=on|off   getpostcookie只对这些东西起作用。
//为了实现功能重用,写成check_form函数单独保存.php
//include("function.php")

//将表数据写入数据表tb_user
//$sql语
//mysql_query()
//$result=mysql_fetch_array()
//$username=@$_POST[name];
//$password=@$_POST[pass];
//$sql="INSERT INTO tb_user(username,password) values('".$username."','".$password."')";
//mysql_query($sql);

//写入成功跳转到login.php

//判断用户是否点击了提交按钮
//if(isset($_POST['op']));
if($_POST['op']=="register"){
include("do_reg.php");
exit;
}
include("header.php");
}

 

 

 

 
?>

<form action="reg1.php" name="forms" method="POST" id="user_register"size="30">
用户名:<input type="text" name="edit[name]"  id="edit-name"/>
密码:<input  type="password"  name="edit[pass]" id="edit-pass" />
重复密码:<input type="password" name="edit[pass1]"  id="edit-pass1"/>
邮箱:<input type="mail" name="edit[m]" id="edit-m">
照片:<input type="photo" name="edit[ph]" id="edit-pho">
电话:<input type="tel" name="edit[t]" id="edit-t">
生日:<input type="birthday" name="edit[bir]" id="edit-bir">
爱好:<input type="like" name="edit[li]" id="edit-li">
自我介绍:<input type="introduce" name="edit[in]" id="in">
注册时间:<input type="reg_time" name="edit[re]" id="edit-re">
分数:<input type="number" name="edit[num]" id="edit-num">
等级:<input type="level" name="edit[le]" id="edit-le">

 <input type="submit" name="ok" value="register" onclick="return check_form(); "/>
 
 
 
 <!--javascript验证各项信息的有效性:第一种<form 
 onsubmit="return check_form();">第二种<input
 onclick="return check_form()">-->
 
 </form>
<!--定义用户注册表单验证js函数,利用正则表达式-->
<script type="text/javascript">
function  check_form(){
//getElementById方法得到指定的标签名称
//IE浏览器自动生成windows对象,
//标签元素对应的属性
//是document的基本属性,window.document等于document
var username=document.getElementById("edit-name").value;
//var username=document.getElementById("edit-name").defautlvalue;
password=document.getElementById("edit-pass").value;
password1=document.getElementById("edit-pass1").value;
//定义出错信息,显示字符串,正常的情况默认为空
msg="";
if(username==""){
//一个”=“在mysql环境下表示比较,
msg+="username is not null! \n";
alert(msg);
}
if(password==""){msg+="password is not null !  \n"
alert(msg);
}
if(password!=password1){msg+="must equel! \n";
alert(msg);
}

if(radiobutton==""){msg+="mail is not null! \n";
alert(msg);
}
if(msg==""){
     alert("成功");
  window.open("login.php");
  return true;
}else{
    alert("失败");
 return false;
}
 

 


}

</script>