<?php
session_start();
include_once("inc/conn.php");
include_once("inc/function.php");
if($_GET["act"]=="reg"){
	if(!$_POST["agreement"]){
		echo "<script language=javascript>alert('您不接受会员服务条款,请您离开这里!');location.href='index.php';</script>";
		exit;
	}
	if($_COOKIE["reg"]==1){
		echo "<script language=javascript>alert('每人只可以注册一个帐号，禁止重复注册!');location.href='index.php';</script>";
		exit;
	}
	if(strtolower($_SESSION["yan"])!=strtolower($_POST["tbSafeCode"])){
		echo "<script language=javascript>alert('验证码错误');history.go(-1);</script>";
		exit;
	}else{
		$tbUserMail=str_check($_POST["tbUserMail"]);
		$tbUserNick=str_check($_POST["tbUserNick"]);
		$tbUserPwd=md5($_POST["tbUserPwd"]);
		$tbUserGender=str_check($_POST["tbUserGender"]);
		$tbUserSecQues=str_check($_POST["tbUserSecQues"]);
		$tbUserSecAns=str_check($_POST["tbUserSecAns"]);
		$query=$db->query("insert into {$web_dbtop}users (email,name,password,sex,secques,secans,points,time,tjid) values 
		('$tbUserMail','$tbUserNick','$tbUserPwd','$tbUserGender','$tbUserSecQues','$tbUserSecAns',$reg_points,'".date("Y-m-d H:i:s")."',".intval($_COOKIE["reguid"]).")");
		$id=$db->insert_id();
		$db->query("insert into {$web_dbtop}game_log (uid,reg_hd) values ($id,$reg_points)");
		setcookie("reg",1,time()+8640);
		setcookie("usersid",$id);
		setcookie("password",$tbUserPwd);
		setcookie("reguid");
		echo "<script>alert('注册成功');location.href='index.php';</script>";
		exit;
	}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>用户注册-<?=$web_name;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<?=$web_keywords;?>" />
<meta name="description" content="<?=$web_description;?>" />
<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<link href="style/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="inc/ajaxrequest.js"></script>
<script type="text/javascript" src="inc/reg.js"></script>
</head>
<?php include_once("top.php");?>
<DIV class="wrapper">
	<DIV class="page_content">
		<DIV class="webgame-activities-title">
			<H3>用户注册</H3>
		</DIV>
		<div class="main_users">
			<div class="main_txzreg">
				<p class="tit_reg"><img src="images/icon_tit01.gif" />&nbsp;&nbsp;欢迎注册<?=$web_name;?>通行证<em>(以下信息皆为必填项，请认真填写！)</em></p>
				 <form onsubmit="return ChkReg()" action="?act=reg" method="post">
					<table width="750" border="0" cellspacing="0" cellpadding="0" class="table_reg">             
						<tr>
						<th width="150">登陆通行证：</th>
							<td width="300"><input name="tbUserMail" class="inpA" id="tbUserMail" onblur="ChkRepeatNick(this.value);"/></td>
							<td width="300"><span id="sUserMail">登陆通行证</span></td>
						</tr>
						<tr>
						<th>通行证密码：</th>
							<td width="300"><input class="inpA" id="tbUserPwd" type="password" maxlength="16" size="25" value="" name="tbUserPwd" /></td>
							<td width="300"><span id="sUserPwd">3～16位，区分大小写 </span></td>
						</tr>
						<tr>
							<th>重复通行证密码：</th>
							<td><input class="inpA" id="tbRePwd" type="password" size="25" value="" name="tbRePwd" /></td>
							<td><span id="sRePwd">请再次输入您的密码</span></td>
						</tr>
						<tr>
						<th>用户昵称：</th>
							<td width="300"><input name="tbUserNick" class="inpA" id="tbUserNick"/></td>
							<td width="300"><span id="sUserNick">中英文皆可</span></td>
						</tr>
						<tr>
							<th>用户性别：</th>
							<td><INPUT type=radio CHECKED value=M name=rUserGender> 先生 <INPUT type=radio value=F name=tbUserGender> 女士</td>
							<td><span id="sUserGender">选择性别</span></td>
						</tr>
						<tr>
							<th>安全提问：</th>
							<td><select class="inpA" id="tbUserSecQues" name="tbUserSecQues">
                              <option value="" selected="selected">请选择机密问题</option>
                              <option value="你父亲的姓名是什么?">你父亲的姓名是什么?</option>
                              <option value="你母亲的姓名是什么?">你母亲的姓名是什么?</option>
                              <option value="你的出生地?">你的出生地?</option>
                              <option value="你的宠物的名子?">你的宠物的名子?</option>
                              <option value="你的职业是什么?">你的职业是什么?</option>
                              <option value="你配偶的职业是什么?">你配偶的职业是什么?</option>
                            </select></td>
							<td><span id="sUserSecQues">请填写，用于忘记密码时取回，<span class="rf">非常重要，请务必牢记。</span></span></td>
						</tr>
						<tr>
							<th>安全答案：</th>
							<td><input class="inpA" id="tbUserSecAns" size="25" name="tbUserSecAns" /></td>
							<td><span id="sUserSecAns">请填写，用于忘记密码时取回，<span class="rf">非常重要，请务必牢记。</span></span></td>
						</tr>
						<tr>
							<th>验证码：</th>
							<td><input name="tbSafeCode" type="text" id="tbSafeCode" style='text-transform:uppercase;' class="inp_yzm"/>&nbsp; <img id="regSafeCode" onclick="$('regSafeCode').src='inc/code.php';" src="inc/code.php" alt="看不清？点击更换" style="cursor:pointer"  width="60" height="26" /> <a href="javascript:showCode();">看不清楚？换个图片</a></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="3" align="center"><div align="center">
						      <INPUT type=checkbox CHECKED value=checkbox name=agreement>
						      我已认真阅读并同意接受 《<A href="zc.php" target=_blank><span class="rf"><?=$web_name;?> 会员服务条款</span></A>》</div></td>
						</tr>
						<tr>
							<th>&nbsp;</th>
							<td class="btn_reg"><input name="" type="submit" class="buttonreg" value=""></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		<div class="area960-b h5px"></div>
		<DIV class=cl></DIV>
	</div>
	<!--Flink End-->
	<div class="blank10"></div>
	<!--Footer Start-->
<?php include_once("footer.php");?>
</DIV>