MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 24th, 2000, 12:12 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to kunal
How would I check wether a email addy already exists in the database?? the table name is members

Reply With Quote
  #2  
Old April 24th, 2000, 01:57 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

just issue a simple query like this.

"SELECT * FROM members WHERE email='shiju@post.com'"

if return value is greater than 0 then the email address is existing in the database.else , not existing in the database.




------------------
SR -
shiju.dreamcenter.net

Reply With Quote
  #3  
Old April 24th, 2000, 02:02 AM
kunal kunal is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 53 kunal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to kunal
WEll could u give me the entire code?? czo thats where i was having a problem..u know something which i could jsut cut-n-paste...my table name is members and the email addy variable whioch the user has inputed is $email or email. Thanx

Reply With Quote
  #4  
Old April 26th, 2000, 01:31 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
Hope the following may work for you..



$con=mysql_connect('localhost','username','password');

mysql_select_db ('databasename',$con);

$result = mysql_query("SELECT * FROM members WHERE email='$email'",$con);

if (mysql_num_rows($result) == 1)
{
# email is existing in the database
$emailexists = 1;
}else{
#Email is not existing...
exit;
}

GOOD LUCK!!


------------------
SR -
shiju.dreamcenter.net

Reply With Quote
  #5  
Old April 29th, 2000, 03:28 AM
ranjeet ranjeet is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: thane
Posts: 50 ranjeet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ranjeet Send a message via Yahoo to ranjeet
shiju the code presented by you will work fine but why

"select * from member where email=$email";

can't it be just simple like

$result="select count(email) as xyz from member where email=$email";

$xyz=mysql_result($result,0,"xyz");

if($xyz)
{
echo "user email exists allready";
//or do whatever
}
else
{
echo "user available";
//ur processing
}


ranjeet



Reply With Quote
  #6  
Old April 29th, 2000, 06:16 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
Ranjeet,

"select email from member where email=$email";

this query will return the no of rows.if no of rows is greater 0 then offcourse the email is existing.

see.. for easy understanding i written that very straight.

What you are writing also is very fine.But you are doing that in different way.

Thank You.











------------------
SR -
shiju.dreamcenter.net

Reply With Quote
  #7  
Old April 29th, 2000, 07:07 AM
ranjeet ranjeet is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: thane
Posts: 50 ranjeet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ranjeet Send a message via Yahoo to ranjeet
yes sir very true

but in ur reply u had given

"select * from member where email=$email";

instead of

"select email from member where email=$email"

that's why i replied in diff way
ne way thanx
ranjeet

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Querying

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap