📄 register.php
字号:
<? include("conn.php");?>
<? include("include/setup.php");?>
<? include("head.php");?>
<?
$userid1=trim($_POST[userid]);
$username1=trim($_POST[username]);
$psw=$_POST[psw];
$email=trim($_POST[email]);
$checkid=0;
$checkemail=0;
if($userid1!=""){
//检测用户名
$qr=mysql_query("select id from myuser where userid='".$userid1."'");
$rs=mysql_fetch_array($qr);
$checkid=$rs[id];
//检测用户email
$qr=mysql_query("select id from myuser where email='".$email."'");
$rs=mysql_fetch_array($qr);
$checkemail=$rs[id];
if(!$checkid && !$checkemail){
$time=time();
mysql_query("insert into myuser (
userid,
username,
psw,
email,
regtime,
logontime)
values
(
'$userid1',
'$username1',
'$psw',
'$email',
'$time',
'$time'
) ");
$_COOKIE['mmei8id']=$userid1;
$isSucess="Yes";
$userid=$userid1;
}
}
?>
<script language="JavaScript">
<!--
function CheckCharacter(String)
{
var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-";
var i;
var c;
for(i=0;i<String.length;i++){
c=String.charAt(i);
if(Letters.indexOf(c)<0)
return false;
}
return true;
}
function CheckUserID(obj){
if((obj.UserID.value.length<3)||(obj.UserID.value.length>20)){
document.all.sUserID.innerHTML='帐号必须是3-20个字符';
return false;
}else if(CheckCharacter(obj.UserID.value)==false){
document.all.sUserID.innerHTML='帐号必须是字母或数字构成';
return false;
}else{
document.all.sUserID.innerHTML='';
return true;
}
}
function CheckPsw(obj){
if((obj.Psw.value.length<6)||(obj.Psw.value.length>18)){
document.all.sPsw.innerHTML='密码必须是6-18个字符';
return false;
}else if(obj.Psw.value!==obj.RePsw.value){
document.all.sPsw.innerHTML='';
document.all.sRePsw.innerHTML='确认密码必须与密码一致';
return false;
}else{
document.all.sPsw.innerHTML='';
document.all.sRePsw.innerHTML='';
return true;
}
}
function CheckEmail(String){
var re;
re=new RegExp("\\w+@((\\w)+\\.)+[a-z]{2,3}$");
return re.test(String);
}
function CheckValidate(obj){
var ValidateCode=obj.ValidateCode.value;
if(ValidateCode.length!=4)
{
document.all.sValidateCode.innerHTML='请输入4位验证码';
return false;
}
else
{
document.all.sValidateCode.innerHTML='';
return true;
}
}
function check(obj){
var CU,CP,CE,OV;
CU=CheckUserID(obj);
CP=CheckPsw(obj);
CE=CheckEmail(obj.Email.value);
OV=CheckValidate(obj);
if(CE){
document.all.sEmail.innerHTML='';
}else{
document.all.sEmail.innerHTML='请正确填写Email地址';
}
if(CU&&CP&&CE&&OV){
return true;
}else{
return false;
}
}
//-->
</script>
<script language="JavaScript">
function submitForm(obj)
{
var title=obj.title.value;
var Sort=obj.Sort.value;
obj.action="searchzhai.php?sort="+Sort+"&title="+escape(title);
return true;
}
</script>
<table width="760" align="center">
<tr>
<td><table width="420" height="27" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="80" class="bgtitley"><a href="listzhai.php?type=hot24">24小时收藏</a></td>
<td width="80" class="bgtitley"><a href="listzhai.php?type=hot48">48小时收藏</a></td>
<td width="80" class="bgtitley"><a href="listzhai.php?type=week">周热点收藏</a></td>
<td width="80" class="bgtitley"><a href="myzhai.php">我 的 收 藏</a></td>
<td class="bgtail"> </td>
</tr>
</table></td>
<td align="right"><form name="form1" method="post" action="" onsubmit="return submitForm(this)" style="margin:0">
<input name="title" type="text" id="title" size="21" maxlength="60">
<select name="Sort" id="Sort">
<option value="标签">标签</option>
<option value="内容">内容</option>
</select>
<input name="submit" type="image" id="submit" src="images/mini_query.gif" alt="提交检索" width="45" height="15" border="0">
</form></td>
</tr>
</table>
<table width="760" border="0" cellspacing="21" cellpadding="0">
<tr class="Notice">
<td align="center"><b>新用户注册</b></td>
</tr>
<tr class="Notice">
<td align="center">
<?
if($isSucess=="Yes"){
echo '<script>
alert("注册成功,请您登陆!");
</script>';
echo "<script>
location.replace('login.php');
</script>";
}else{
if(($checkid+$checkemail)!=0){
echo("注册失败");
}
if($checkid!=0){
echo("-此用户名已经被注册使用");
}
if($checkemail!=0){
echo("-此email已经被注册过");
}
;?>
</td>
</tr>
</table>
<form name="form1" method="post" onsubmit="return check(this);" action="register.php" style="margin-bottom:0;margin-top:0">
<table width="760" border="0" cellspacing="6" cellpadding="0">
<tr>
<td width="40%" align="right">用户id:</td>
<td width="60%"><input name="userid" type="text" id="userid" maxlength="30" value="<? echo $userid1;?>"> <span class="Notice" id=suserid>*</span></td>
</tr>
<tr>
<td align="right">用户名称:</td>
<td><input name="username" type="text" id="username" value="<? echo $username1;?>">
</tr>
<tr>
<td align="right">密码:</td>
<td><input name="psw" type="password" id="psw" value="<? echo $psw;?>">
<span class="Notice" id=spsw>*</span></td>
</tr>
<tr>
<td align="right">重复密码:</td>
<td><input name="Repsw" type="password" id="Repsw" value="<? echo $psw;?>">
<span class="Notice" id=sRepsw>*</span></td>
</tr>
<tr>
<td align="right">email:</td>
<td><input name="email" type="text" id="email" value="<? echo $email;?>">
<span class="Notice" id=semail>*</span></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="Submit" value="提交注册信息"></td>
</tr>
</table>
<table width="760" height="150" border="0" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
</form>
<?
}
?>
<? include("bottom.php");?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -