the script wont check for used usernames, and if a username that is already used is entered, it still creates the user in the database... why?
<?PHP
if($HTTP_POST_VARS['submit']) {
if (mysql_connect("localhost","root","pas
s")
or die ("<div align=center><span class=text>Unable to connect to the database. Try again later.</span></div>")) {
mysql_select_db('root');
} else
print "Couldn't connect!<br>";
if (!$username || !$userpass || !$confirmp || !$useremail) {
echo '<div align=center><span class=text>You have not entered all the fields. Please go back and fix the missing fields.</span></div>';
exit;
} Else if ($userpass != $confirmp) {
echo '<div align=center><span class=text>Your passwords do not match</span></div>';
exit;
// new part added
} Else if (($userpass==$confirmp) && $username!=="" && $useremail!=="") {
$result2 = mysql_query("SELECT user_name FROM users WHERE user_name='".$_POST['username']."'");
$nameexists = mysql_num_rows($result2);
if ($nameexists == 1) {
echo "<span class=text>Name exists already. Please create a new name.</span>";
} else {
mysql_query("INSERT INTO users (user_name, user_pass, user_email, user_aimaol, user_msn, user_icq, user_admin) VALUES ( '$username', '$userpass', '$useremail', '$useraimaol', '$usermsn', '$usericq', '$useradmin' ) ")
or die ("<div align=center><span class=text>Unable to create user. Try again later.</span></div>");
header('Location: emailer.php');
} // end if
} // end elseif
//
} //end else
?>
and then my emailer doesnt work ehre
PHP:
<?PHP
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Bcc: [email]noreply@mysite.com[/email]\r\n";
$to = $useremail;
$message = "Thank you for registering with mysite. Please make sure you follow the <a href='http://mysite.com/rules.php'>rules</a>.<br><br>Information registered with:<br><br>Username: ".$username."<br>Password: ".$password."<br>AIM/AOL: ".$useraimaol."<br>MSN: ".$usermsn."<br>ICQ: ".$usericq."<br><br>Please keep this email so you don't forget login information. Thanks.";
$subject = "mysite Registration";
mail ($to, $subject, $message, $headers);
?>