<?php
$status = "user";
$name = $_POST['name'];
$username = $_POST['username'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$address = $_POST['address'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$birthdate = implode("-",$bd);
$gender = $_POST['gender'];
if(empty($name)) {
echo "You haven't defined your name";
exit();
}
if (!eregi("[a-z0-9]{4,}",$username)) {
echo "Username must consist of 4 or more characters with only a-z and 0-9 allowed";
exit();
}
if($password != $cpassword) {
echo "Your passwords are not matched";
exit();
}
if(!eregi("[a-z0-9]{4,}", $password)) {
echo "Your password must consist of 4 or more characters with only a-z and 0-9 allowed";
exit();
}
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Your email is not valid";
exit();
}
include('db_connector.php');
$checkadd = "select*from `userinfo` where username='$username'";
$result = mysql_db_query($dbname,$checkadd);
$num = mysql_num_rows($result);
if ($num >= 1) {
echo "Your username has already been used by another user, please use another name";
}
else {
$sql = "insert into `userinfo`(`name`,`status`,`username`,`password`,`address`,`email`,`tel`,`birthdate`,`gender`) values ('$name','$status','$username','$password','$address','$email','$tel','$birthdate','$gender')";
mysql_query("set NAMES UTF8");
$sqlquery = mysql_db_query($dbname,$sql);
echo "Your data has been recorded";
}
mysql_close();
?>