<html>
<head>
<title>Thank You For Registering With Us!!! </title>
</head>
<body>
<?php
include 'connect.php';
// Define post fields into simple variables
$full = $_POST['full'];
$user = $_POST['user'];
$nric =$_POST['nric'];
$address =$_POST['address'];
$postal =$_POST['postal'];
$email = $_POST['email'];
$password = $_POST['password'];
$hp=$_POST['hp'];
$home=$_POST['home'];
$day=$_POST['Extra4'];
$month=$_POST['Extra5'];
$year=$_POST['Extra6'];
$gender = $_POST['gender'];
/* Let's strip some slashes in case the user entered
any escaped characters. */
$full = stripslashes($full);
$user = stripslashes($user);
$nric = stripslashes($nric);
$address = stripslashes($address);
$postal = stripslashes($postal);
$email = stripslashes($email);
$hp = stripslashes($hp);
$home = stripslashes($home);
/* Do some error checking on the form posted fields */
if((!$user) || (!$address) || (!$postal) || (!$email) || (!$password) || (!$cpassword) || (!$hp){
echo 'You did not submit the following required information! <br />';
if(!$user){
echo "User Name is a required field. Please enter it below.<br />";
}
if(!$address){
echo "Address is a required field. Please enter it below.<br />";
}
if(!$postal){
echo "Postal Code is a required field. Please enter it below.<br />";
}
if(!$email){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$password){
echo "Password is a required field. Please enter it below.<br />";
}
if(!$cpassword){
echo "Please confirm your password. Please enter it below.<br />";
}
if(!$hp){
echo "Please enter your HP number. Please enter it below.<br />";
}
include 'registration.html'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_email_check = mysql_query("SELECT email FROM members WHERE email='$email'");
$sql_username_check = mysql_query("SELECT user FROM members WHERE user='$user'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />";
unset($email);
}
if($username_check > 0){
echo "The username you have selected has already been used by another member in our database. Please choose a different Username!<br />";
unset($user);
}
include 'registration.html'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
// Enter info into the Database.
$sql = mysql_query("INSERT INTO members (full, user, nric, address, postal, email, password, hp, home, day, month, year, gender, signup_date)
VALUES('$full', '$user', '$nric', '$address', '$postal', '$email', '$password', '$hp', '$home', '$day', '$month', '$year', '$gender', now())") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
// Let's mail the user!
$subject = "Your Membership at Ebuzz!";
$message = "Dear $user ,
Thank you for registering at our website, [url]http://www.mydomain.com[/url]!
You will be able to login with the following information:
Username: $user
Password: $password
Thanks!
The Webmaster
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: MyDomain Webmaster<admin@mydomain.com>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}
?> </body>
</html>