For handling the email already in use problem:
$issue = htmlentities(mysql_real_escape_string(stripslashes(GET['issue'])));
if ($issue == "email") {
echo "Email already in use";
}
if ($issue == "invsalid") {
echo "Invalid email";
}
And the code for checking and registering a user:
$email = post['email'];
//Prevent SQL Injection
$email = htmlentities(mysql_real_escape_string(stripslashes($email)));
if ( eregi ( '[a-z||0-9]@[a-z||0-9].[a-z]', $email ) ) { //checks to make sure the email address is in a //valid format
$domain = explode( "@", $email ); //get the domain name
//if ( @fsockopen ($domain[1],80,$errno,$errstr,3)) {
//if the connection can be established, the email address is probably valid
$sql1 = "SELECT * FROM Members where email='$email';";//could use SQL count function instead
$result1 = mysql_query($sql1);
$count1 = mysql_num_rows($result1);
if ($count1 >= 1) {
header("Location: register.php?issue=email");
} else {
//add user to database
}
} else {
header ("Location: register.php?issue=invalid:);
}
You could also use jQuery and AJAX to alert the user if the email is already taken as they type.
Hope this helps!