echo file_get_contents('template/header.html'); ?>
require('includes/db.php');
require('includes/settings.php');
displayTitle("Register for a NEW Account");
$username = $_POST['username'];
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
$vvc = $_POST['vvc'];
$repeatPassword = $_POST['repeatPassword'];
//The complicated Validation
$error = false;
if (isset($_POST["submit"])) {
if (!isset($username) or $username == "" or $username == " ") {
echo "Error: You must specify a username!
";
$error = true;
} else {
$aQuery = mysql_query ("SELECT * FROM stagdata_user where UPPER(username)='".strtoupper($username)."'");
if ($row = mysql_fetch_array($aQuery)) {
echo "Error: Username Already Exists
";
$error = true;
}
}
if (!isset($password) or $password == "" or $password == " ") {
echo "Error: You must specify a password!
";
$error = true;
} else {
if (!isset($repeatPassword) or $repeatPassword == "" or $repeatPassword == " ") {
echo "Error: You must repeat the password!
";
$error = true;
} else {
if ($repeatPassword != $password) {
echo "Error: Your passwords do not match!
";
$error = true;
}
}
}
if (!isset($email) or $email == "" or $email == " ") {
echo "Error: You must specify an email address!
";
$error = true;
} else {
if (strpos($email, "@") < 1) {
echo "Error: Email address does not appear to be valid!
";
$error = true;
} else {
$aQuery = mysql_query ("SELECT * FROM stagdata_user where UPPER(email)='".strtoupper($email)."'");
if ($row = mysql_fetch_array($aQuery)) {
echo "Error: Email Address Already Registered
";
$error = true;
}
}
}
if (!isset($name) or $name == "" or $name == " ") {
echo "Error: You must specify a name!
";
$error = true;
}
if ($vvc != "st8g") {
echo "Error: Visual Verification Code Incorrect!
";
$error = true;
}
}
if (isset($_POST["submit"]) and !$error) {
$sqlQuery = "INSERT INTO stagdata_user (username, name, email, password) value ('$username','$name','$email', '".md5($password)."')";
//echo $sqlQuery;
if (mysql_query($sqlQuery)) {
$aQuery = mysql_query ("SELECT id FROM stagdata_user where email='".$email."'");
if ($row = mysql_fetch_array($aQuery)) {
$confirm_id = $row['id'];
}
$recipient = $email;
$mail_body = "Please click on the following link to confirm your account
".$http_home_url."register_confirm.php?auth=".md5($email)."&id=".$confirm_id."";
$subject = $system_from_subject_prefix." email confirmation, please action....";
$header = "From: ".$system_from_name." <".$system_from_email.">\r\n".'Content-Type: text/html; charset="iso-8859-1"\r\n';
mail($recipient, $subject, $mail_body, $header);
echo "Successfully created account, please check your email and confirm your account! Thanks!";
} else {
echo "Sorry, there has been a problem creating your account, please contact Glenn or FieldIT"; //Glenn please put what you like here!
}
} else {
?>
}
?>
echo file_get_contents('template/footer.html'); ?>