<?php
include '../comm/conn.php';
include '../comm/checkpostandget.php';
include 'check.php';

$je=$_POST['txje'];
$zfb=$_POST['zfb1'];

if($je==""||$zfb=="")
{
    header('Location: ../comm/error.php?err=6');
    exit;
}

$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) 
{
     die('数据库链接出错: ' . mysql_error());
	 exit;
}
mysql_select_db($dbname);

mysql_query("set names gbk");
//检查用户名是否被注册
$q = "SELECT * FROM user where ddusername='".$username."'";

$rs = mysql_query($q);
while ($row = mysql_fetch_array($rs))
{
		$yjs=$row[yjs];
		$txstate=$row[txstate];
		$ip=$_SERVER["REMOTE_ADDR"];
}
if($yjs<$je)
{
	header('Location: ../comm/error.php?err=7');
	exit;
}
//用户名可用，注册用户
else
{
	if($txstate==0)
	{
		$sj= date("Y-m-d H:i:s");
		mysql_query("set names gbk");
		$insert = "INSERT INTO tixian(ddusername,txje,zfb,addtime,addip,txstate) values ('$username','$je','$zfb','$sj','$ip','0')";
		mysql_query($insert);
		//echo $insert;
		//更新提现信息，可提现金额现在不变，等管理员审核后再修改！
		$up = "update user set txstate=1,zfb='$zfb',lasttixian='$sj' where ddusername='".$username."'";
		mysql_query($up);
		header('Location: tixianok.php');
		exit;
	}
	else
	{
		header('Location: ../comm/error.php?err=12');
		exit;
	}
}     

mysql_close($link);

?>
