$user = htmlspecialchars($_POST['username']);
$pass1 = $_POST['password'];
$pass2 = $_POST['password2'];
$email = $_POST['email'];
$birth = $_POST['birthday'];
$tel = $_POST['tel'];
$query = "SELECT * FROM userbase";
$result = mysql_query($query);
$num_of_user = mysql_num_rows($result); $num_of_user++;
$activatekey = md5(rand(1, 1000000));
$password=md5($pass1);
$usertime=date("d M Y");
$query = "INSERT INTO userbase (Username, id, Password, Email, Birthday, tel, Regtime, KeyValue, Activate, LastVisit, Privilegies)
VALUES ('$user', '$num_of_user', '$password', '$email', '$birth', '$tel', '$usertime', '$activatekey', '0', '$Regtime', '6')";
$result = mysql_query($query);
$query = "DELETE FROM userbase WHERE TO_DAYS(CURDATE())-TO_DAYS(str_to_date(regtime,\"%d %b %Y\"))>3 AND activate=0";
mysql_query($query);