PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$query = "SELECT id FROM login WHERE username='$username'";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
if (mysql_num_rows($result) == 0) {
} else {
echo '<p><font color="red" size="+1">That username has allready been registered.</font></p>';
}
but it says That username has allready been registered but then it registers you. If I include exit(); they have to hit back to see the page again and I don't wan't that so how do i like make the script stop from there and not register the person, thanks
Where is your actual registration code for them to register you?
If its after the above code, of course it would still register you unless you:
1. Replaced the registration code within the if statement so that only if the username isn't taken, it would continue on with the registration or
2. Set an bool $error whenever an error occurs and check whether the bool is true or false before it continues on to register.
Of course there are other alternatives too, but those are the basic ones.
if (mysql_num_rows($result) == 0) {
$username_available = true;
} else {
$username_available = false;
echo '<p><font color="red" size="+1">That username has allready been registered.</font></p>';
}
:snip:
if ($username && $email && $password && $rank && $division && $username_available) {
:snip:
} else { // If it did not run OK.
echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';
}
I know, but the reason why it did not run ok is because the username is allready taken. I don't wan't that message there because there is allready a message saying the username is taken. I put it there incase of SQL error.