Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unique Username/Password

Status
Not open for further replies.

sipps

Technical User
Feb 9, 2003
133
GB
Hi,

Could anyone tell me how I can make sure that when a new customer is set up, that they provide a username and password that is unique, and not already in the database?

Thanks
 
You could perform a query that selects that username from your table with users. If this query returns any rows, that means that the username already exists. //Daniel
 
Thanks Daniel,

I'm not really sure how to code that, I know what I want it to say!

If Username>0
then message "Sorry, that username is taken"
else
Insert into Customer...

I would want them to enter this username and password when they register as a customer, so they enter their address, telephone number and email at the same time. I have a bit of javascript that runs onClick of the submit button. This checks that there are values in each of the text fields, and also checks validates the password by entering it twice etc.
How would I run this query before inputing all the otehr data into the db?

Thanks
 
$Queuser=mysql_query("select username from Custome where username='$username'");
$nrow= mysql_num_rows($Queuser);
if ($nrow >= 1){
echo"$username username already exists. ";
exit;
}else{
....Insert into Customer...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top