PDA

View Full Version : Need some help with code to use


Parker Clack
05-29-2002, 08:59 AM
In the register.php file it will check to see if a username is already taken and not allow a person to sign up if it is already in use.

Instead of just removing all the usernames that haven't posted on the forum for a long time or never posted I created another usergroup to move those members into that area.

What I want to be able to do though is not include those members in that usergroup with the username check that the script uses.

In register.php the script uses

if ($checkuser=$DB_site->query_first("SELECT username FROM user WHERE username='".addslashes(htmlspecialchars($username))."' OR username='".addslashes(eregi_replace("[^A-Za-z0-9]","",$username))."'")) {
eval("standarderror(\"".gettemplate("error_usernametaken")."\");");
exit;
}

How would I need to rewrite this so that if the usergroupid=14 (this is the number of the usergroupid that I have assigned to this new area) then it skips the error_usernametaken template?

Thanks in advance for any suggestions.

Parker

Darren Lewis
05-29-2002, 09:33 AM
Hi Parker,

Will this work (I'm only in the learning stages of writing PHP)?


if ($checkuser=$DB_site->query_first("SELECT username, usergroupid FROM user WHERE username='".addslashes(htmlspecialchars($username))."' OR username='".addslashes(eregi_replace("[^A-Za-z0-9]","",$username))."'")) {
while ($newvariable1=$DB_site->fetch_array($checkuser))
{
$newvariable2=$newvariable1['usergroupid'];
if ($newvariable2 == 14)
{
exit;
}
else
{
eval("standarderror(\"".gettemplate("error_usernametaken")."\");");
exit;
}
}
}


Darren.

Parker Clack
05-29-2002, 09:50 AM
Darren:

I am not sure either as I do not know PHP code that well myself.

I will give it a shot and see.

Thanks,
Parker

Admin
05-29-2002, 10:09 AM
This will do the trick:
if ($checkuser=$DB_site->query_first("SELECT username FROM user WHERE usergroupid<>14 AND (username='".addslashes(htmlspecialchars($username))."' OR username='".addslashes(eregi_replace("[^A-Za-z0-9]","",$username))."')")) {
14 being that special usergroup's ID.

Parker Clack
05-29-2002, 10:26 AM
Chen and Darren:

Thanks for the help. I will try this out later today.

Parker

Parker Clack
05-29-2002, 10:33 AM
Thanks guys. I went with Chen's suggestion as its less code. Less confusing for me that way. :)

Chen what does <> equal? Is that less than or great than?

Parker

Darren Lewis
05-29-2002, 11:14 AM
I agree, Chen's method is much simpler :)

<> means not equal and is the same as !=