Thank you for signing up with Community Service 101.com
Your Login Details:
Username:$username
Password:$password
";
//Message Headers and Subject
$subject = "Re: Community Service 101 Registration Information";
$headers="From: CommunityService101 \r\n"
."Reply-To: no-reply@CommunityService101.com\r\n"
."Content-Type: text/html\r\n";
//Send Email
mail($email,$subject,$message,$headers);
}
if (isset($_POST['submit']))
{
if (!($_POST['firstname']) or !($_POST['lastname']) or !($_POST['username']) or !($_POST['email']) or !($_POST['phonenumber']) or !($_POST['password']) or !($_POST['county']) or !($_POST['hours']))
{
header("Location: register.php?status=1");
exit;
}
else
{
$firstname=htmlspecialchars($_POST['firstname']);
$lastname=htmlspecialchars($_POST['lastname']);
$username=htmlspecialchars($_POST['username']);
$email=htmlspecialchars($_POST['email']);
$phonenumber=htmlspecialchars($_POST['phonenumber']);
$password=htmlspecialchars($_POST['password']);
$county=htmlspecialchars($_POST['county']);
$hours=htmlspecialchars($_POST['hours']);
}
//Checks if the username is in use
$check_username = mysql_query("SELECT `ID` FROM `users` WHERE `username`='".$username."'")
or die(mysql_error());
$total_results = mysql_num_rows($check_username);
//Check to see if the email is valid
$inwhere=$email;
$pattern = "/(@)/";
if (!(preg_match_all($pattern,$inwhere,$dat)==1))
{
header("Location: register.php?status=2");
exit;
}
//If the name is already taken it lets them know
if ($total_results != 0) {
header("Location: register.php?status=3&username=".$username."");
exit;
}
//Insert user data into the database
$insert = "INSERT INTO users (`username`,`password`,`email`,`firstname`,`lastname`,`phone`,`county`,`hours`)
VALUES ('".$username."','".$password."','".$email."','".$firstname."','".$lastname."','".$phonenumber."','".$county."','".$hours."')";
$add_member = mysql_query($insert);
//Email username and password
send_email($email,$username,$password);
//Set session data
$session_data = array($username,$password);
$session_data = serialize($session_data);
$_SESSION['memberid'] = $session_data;
//Redirect to the members page
header("Location: members.php");
exit;
}
?>