php简单注册页面代码
注册页面zhuce.html
<html>
<head>
<title>申请帐号</title>
</head>
<head>
<title>申请帐号</title>
</head>
<form method="post" action="insert.php" name="send" onSubmit="return Check()">
<td width="210" class="p11" valign="bottom"><font color="#FF6699">*</font>为必填项</td>
<p>用户名:
<input type="text" name="username" size="20" class="c3a">
<font color="#FF6699">*</font>
<td width="210" class="p11" valign="bottom"><font color="#FF6699">*</font>为必填项</td>
<p>用户名:
<input type="text" name="username" size="20" class="c3a">
<font color="#FF6699">*</font>
</p>
<p>密码:
<input type="password" name="password" size="20" class="c3a">
<font color="#FF6699">*</font></p>
<p>确认密码:
<input name="cpassword" type="password" id="cpassword">
<font color="#FF6699">*</font></p>
<p>email:<label>
<input name="email" type="text" id="email">
</label>
<font color="#FF6699">*</font></p>
<label></label>
性别:男
<input type="radio" name="sex" value="male" />
<p>密码:
<input type="password" name="password" size="20" class="c3a">
<font color="#FF6699">*</font></p>
<p>确认密码:
<input name="cpassword" type="password" id="cpassword">
<font color="#FF6699">*</font></p>
<p>email:<label>
<input name="email" type="text" id="email">
</label>
<font color="#FF6699">*</font></p>
<label></label>
性别:男
<input type="radio" name="sex" value="male" />
<label></label>
<p>女
<input type="radio" name="sex" value="female" />
保密
<input type="radio" name="sex" value="secret" />
</p>
<p>
验证码:
<input name="code" type="text" class="c3a" size="8">
<img src="code.php?" alt="点击刷新" onClick="this.src=this.src+'?'" /></p>
<p>
<input type="submit" value="下一步" >
<input type="reset" value="重来">
</p>
</form>
<p>女
<input type="radio" name="sex" value="female" />
保密
<input type="radio" name="sex" value="secret" />
</p>
<p>
验证码:
<input name="code" type="text" class="c3a" size="8">
<img src="code.php?" alt="点击刷新" onClick="this.src=this.src+'?'" /></p>
<p>
<input type="submit" value="下一步" >
<input type="reset" value="重来">
</p>
</form>
<script language="javascript">
function Check()// 验证表单数据有效性的函数
{
if (document.send.username.value=="")
{
window.alert('请输入用户名!');
return false;
}
if (document.send.username.value.length<4)
{
window.alert('用户名长度必须大于4!');
return false;
}
function Check()// 验证表单数据有效性的函数
{
if (document.send.username.value=="")
{
window.alert('请输入用户名!');
return false;
}
if (document.send.username.value.length<4)
{
window.alert('用户名长度必须大于4!');
return false;
}
if (document.send.password.value=="")
{
alert('请输入密码!');
return false;
}
if (document.send.password.value.length<6)
{
alert('密码长度必须大于6!');
return false;
}
if (document.send.password.value!= document.send.cpassword.value)
{
alert('确认密码与密码不一致!');
{
alert('请输入密码!');
return false;
}
if (document.send.password.value.length<6)
{
alert('密码长度必须大于6!');
return false;
}
if (document.send.password.value!= document.send.cpassword.value)
{
alert('确认密码与密码不一致!');
return false;
}
if (ail.value=="")
{
alert('请输入Email!');
return false;
}
if(ail.value.indexOf("@")==-1)
{
alert('请输入有效的email地址!'); return false;
}
if (de.value=="")
{
alert('请输入验证码!');
}
if (ail.value=="")
{
alert('请输入Email!');
return false;
}
if(ail.value.indexOf("@")==-1)
{
alert('请输入有效的email地址!'); return false;
}
if (de.value=="")
{
alert('请输入验证码!');
return false;
}
return true;
}
</script>
</body>
</html>
插入页面insert.php
<?php session_start();
$conn=mysqli_connect("localhost","root","root","userman");
$conn->query('set names gb2312');
if(empty($conn))
{
$conn=mysqli_connect("localhost","root","root","userman");
$conn->query('set names gb2312');
if(empty($conn))
{
die("数据库连接失败");
}
$UserName=$_POST['username'];
$pwd=$_POST['password'];
$email=$_POST['email'];
$sex=$_POST['sex'];
$time=time();
$code=strtolower($_POST["code"]);
$str="select * from users where username='".$username."'";
$result1=$conn->query($str);
$row=$result1->fetch_row();
if($row)
{
$temp="已有人注册此名,请重新选择名字!";
echo $temp;
}
$UserName=$_POST['username'];
$pwd=$_POST['password'];
$email=$_POST['email'];
$sex=$_POST['sex'];
$time=time();
$code=strtolower($_POST["code"]);
$str="select * from users where username='".$username."'";
$result1=$conn->query($str);
$row=$result1->fetch_row();
if($row)
{
$temp="已有人注册此名,请重新选择名字!";
echo $temp;
echo"<a href=zhuce.php>返回</a>";
}
else {
if( $_SESSION['sname']==$code)
{
echo $temp="认证码成功";
$sql="INSERT INTO users VALUES('$username', '$password','$email','$sex','$time')";
$result=$conn->query($sql);
if($result==true)
{
$_SESSION['mail']="注册成功,请登陆";
echo "<script>window.location.href='login1.php'</script>";
}
else {echo "注册失败".mysql_error();}
}
}
else {
if( $_SESSION['sname']==$code)
{
echo $temp="认证码成功";
$sql="INSERT INTO users VALUES('$username', '$password','$email','$sex','$time')";
$result=$conn->query($sql);
if($result==true)
{
$_SESSION['mail']="注册成功,请登陆";
echo "<script>window.location.href='login1.php'</script>";
}
else {echo "注册失败".mysql_error();}
}
else {echo "认证码错误";}
}
?>
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form action="zc_ok.php" method="post" onsubmit="javascript:var emailPat='^[a-zA-Z0-9]{
1}[\.a-zA-Z0-9_-]*[a-zA-Z0-9]{1}@[a-zA-Z0-9]+[-]{0,1}[a-zA-Z0-9]+[\.]{1}[a-zA-Z]+[\.]{0,1}[a-zA-Z]+$'; var matchArray=email.value.match(emailPat); if (matchArray == null) {alert('请检查您的信箱地址填写是否有误!'); email.focus(); return false;}">
<strong>姓名:<input type="text" name="name"><br></strong>
<br>
<strong> 密码:<input type="password" name="password"><br></strong><br>
<strong>验证密码:<input type="password" name="password1"><br></strong><br>
<strong>性别:<input type="radio" value="1" name="sex" checked>html实现用户注册登录代码男生 <input type="radio" value="0" name="sex" >女生<br>
<p><strong>邮箱:</strong><input type="text" name="email"><br></p>
<input type="submit" value="确定">
<input type="reset" value="重新设定">
</form>
</body>
</html>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论