Current location: Hot Scripts Forums » Programming Languages » PHP » Check if username or email already exists


Check if username or email already exists

Reply
  #1 (permalink)  
Old 06-11-06, 04:00 PM
zitwep zitwep is offline
Wannabe Coder
 
Join Date: Aug 2005
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Check if username or email already exists

Hey,

I am building a registration form and so far coming along great, but now i am stuck in front of something i have never really worked before yet.

Before people register i somehow have to check the database for the email and username they submitted so no double registrations occur. But I have no idea once i got the array with all usernames by for example
Code:
SELECT user_name FROM login_table
how to check if the provided username is in this error.

Can someone help me and point me in the right direction please?

Thanks for your help as usual
zitwep
Reply With Quote
  #2 (permalink)  
Old 06-11-06, 04:27 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
PHP Code:

<?php


$query 
mysql_query("SELECT * FROM user_table WHERE user_name = '"$username ."' OR email = '"$email ."'");

if (
mysql_num_rows($query) > 0)
{
     echo 
'Username or email already in use.';
}

?>
Untested but should work.
Reply With Quote
  #3 (permalink)  
Old 06-12-06, 04:53 AM
zitwep zitwep is offline
Wannabe Coder
 
Join Date: Aug 2005
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Ok that did it,

thank you a lot for your great help on these forums

Greetz
zitwep
Reply With Quote
  #4 (permalink)  
Old 10-13-10, 05:51 AM
moeenakhtar moeenakhtar is offline
New Member
 
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question hi

hi ...........dear did u checked this code???

if user entered the email address like example@hotmail.com and example@Hotmail.com is already stored in db.

it will be allowing user to signup with the same id, but i think it should not allow to signup!!! I am facing this problem. Kindly Help
Reply With Quote
  #5 (permalink)  
Old 10-13-10, 09:13 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Are you sure? MySQL SELECT queries are case insensitive, so that shouldn't be a problem, unless you do something that I don't in my code.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Would like some help understanding this php part. clantron PHP 12 03-12-06 08:24 PM
[SOLVED] check if directory exists lordy PHP 2 07-04-05 01:17 AM
how do i check to see if something already exists in a column in a DB tisza PHP 2 01-06-04 06:54 PM


All times are GMT -5. The time now is 07:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.