Page 1 of 1
Registration
Posted: Sat Jan 06, 2007 5:58 am
by TheCase
Hi I am putting this code in my registration file
Code: Select all
$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
Posted: Sat Jan 06, 2007 6:21 am
by hrubos
I think your problem can be in when you posted pege.Because I saw ur code, I haven't found error there
Posted: Sat Jan 06, 2007 6:30 am
by TheCase
My orginal code in other posts are old. I have redone the regstration page. If thats what you are talking about.
Posted: Sat Jan 06, 2007 7:47 am
by mickd
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.
Posted: Sat Jan 06, 2007 7:53 am
by TheCase
That's just a bit of the code the whole thing is
Code Removed.
Posted: Sat Jan 06, 2007 8:19 am
by mickd
Before registering, your script checks whether any of the checks have failed, except the username taken validation..
Try changing the if/else statement in the block of code you first posted to:
Code: Select all
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>';
}
and also modifying your check to see whether the username is available or not before registering
Code: Select all
if ($username && $email && $password && $rank && $division && $username_available) {
Posted: Sat Jan 06, 2007 9:58 am
by TheCase
Yup. That worked I got the error message username allready taken then i get the error
You could not be registered due to a system error. We apologize for any inconvenience.
why do I get both here is the code again
code removed by author
Thanks for your help
Posted: Sat Jan 06, 2007 10:01 am
by feyd
The code is commented to tell you why, but ...
TheCase wrote:Code: Select all
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>';
}
Posted: Sat Jan 06, 2007 10:18 am
by TheCase
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.
Posted: Sat Jan 06, 2007 10:59 am
by feyd
TheCase wrote:I put it there incase of SQL error.
The code I quoted would suggest otherwise.