This topic is locked

Check if Username is in use

9/23/2007 2:10:51 PM
PHPRunner General questions
D
dorlisa author

*Before someone registers, I want my

(username) field in my (_members) table to check to see if that name is already in use,

if it is in use, then I want it to tell them "Name already in use, choose another username"

if it is not in use, then they should proceed with the registration
I see the "before registration" event under Events, but I don't know which action to use and how to change the code.

Can you check to see if I have chosen the right action and if everything is right?
//****
Check if specific record exists ****

global $conn;

$strSQLExists = "select * from _members where AnyColumn='username'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{

// if record exists do something

}

else

{

// if dont exist do something else

}
return true;
// return true if you like to proceed with registration

// return false otherwise

J
Jane 9/24/2007

Hi,
here is the correct code:

//** Check if specific record exists ****

global $conn;

$strSQLExists = "select * from _members where username='".$userdata["username"]."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{

echo "Name already in use, choose another username";

return false;

}

else

{

return true;

}

bbarker 1/25/2008

So, before I start hacking my code... this feature seems to be in V 4.1 already... Right?
Feature: Prevent duplicate registrations by same "name" or same "email".

J
Jane 1/28/2008

Bill,
username is checked automatically in all PHPRunner versions.

To check unique email add "password-reminder page" on the Security tab.