Here is the code I have.
<?php
include("db.php");
if (isset($_POST['username']) && isset($_POST['passwords']) && isset($_POST['email']))
{
$username = mysql_real_escape_string($_POST['username']);
$email = mysql_real_escape_string($_POST['email']);
$password = md5($_POST['passwords']);
$ip = $_SERVER['REMOTE_ADDR'];
$sql3 = mysql_query("SELECT username FROM usersystem WHERE username = '$username'");
If (mysql_num_rows($sql3) >0)
{
echo( "&serverResponse=Select a different user name. This one is already in use.");}
$sql2 = mysql_query ("SELECT email FROM usersystem WHERE email = '$email'");
If (mysql_num_rows ($sql2) >0)
{
echo( "&serverResponse=This e-mail address is already registered.");
}
mysql_query("INSERT INTO usersystem (username, password, email, ipadd) VALUES ( '$username', '$password', '$email', '$ip')")
or die (mysql_error());
}
If (mysql_num_rows($sql3) >0)) {
echo ("&serverResponse=Success");
$sendTo = $email;
$subject = "Registration Confirmation";
$headers = "From: " . "email@domain.com";
$message = "\nDear " . $username;
$message .= "\nThank you for registering. Your log in information is as follows:";
$message .= "\nUsername: " . $username;
$message .= "\nPassword: " . $password;
mail($sendTo, $subject, $message, $headers);
}
else {
echo ("&serverResponse=There was an error, please try again.");
}
?>
If I remove everything below line 34, it will validate and register the user (but then no e-mail is sent). If I have anything below line 33 (even if I remove the bracket)it will not validate that the username and e-mail address are unique nor put out a server response. I'm fairly new to PHP. Can anyone tell me what is wrong with this script? I have been changing and altering and attempting to get it right for a while now and I can't seem to. :confused: