<?php
error_reporting(0);
if(!isset($_POST['submit'])){
	exit('Ƿ!');
}
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
//עϢж
if(!preg_match('/^[\w\x80-\xff]{3,15}$/', $username)){
	exit('ûϹ涨<a href="javascript:history.back(-1);"></a>');
}
if(strlen($password) < 6){
	exit('볤ȲϹ涨<a href="javascript:history.back(-1);"></a>');
}
if(!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', $email)){
	exit('󣺵ʽ<a href="javascript:history.back(-1);"></a>');
}
//ݿļ
include('conn2.php');
//ûǷѾ
$check_query = mysql_query("select uid from user where username='$username' limit 1");
if(mysql_fetch_array($check_query)){
	echo 'û ',$username,' Ѵڡ<a href="javascript:history.back(-1);"></a>';
	exit;
}
//д
$password = MD5($password);
$regdate = time();
$sql = "INSERT INTO user(username,password,email)VALUES('$username','$password','$email')";
if(mysql_query($sql,$conn)){
	header("Location: login.html");
} else {
	echo 'Ǹʧܣ',mysql_error(),'<br />';
	echo '˴ <a href="javascript:history.back(-1);"></a> ';
}
?>
