★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum4/HTML/000385.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  MySQL
  Querying

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Querying
kunal
Junior Member
posted April 23, 2000 11:12 PM     Click Here to See the Profile for kunal   Click Here to Email kunal     Edit/Delete Message Reply w/Quote
How would I check wether a email addy already exists in the database?? the table name is members

Shiju Rajan
Member
posted April 24, 2000 12:57 AM     Click Here to See the Profile for Shiju Rajan   Click Here to Email Shiju Rajan     Edit/Delete Message Reply w/Quote

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

kunal
Junior Member
posted April 24, 2000 01:02 AM     Click Here to See the Profile for kunal   Click Here to Email kunal     Edit/Delete Message Reply w/Quote
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

Shiju Rajan
Member
posted April 26, 2000 12:31 AM     Click Here to See the Profile for Shiju Rajan   Click Here to Email Shiju Rajan     Edit/Delete Message Reply w/Quote
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

ranjeet
Member
posted April 29, 2000 02:28 AM     Click Here to See the Profile for ranjeet   Click Here to Email ranjeet     Edit/Delete Message Reply w/Quote
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


Shiju Rajan
Member
posted April 29, 2000 05:16 AM     Click Here to See the Profile for Shiju Rajan   Click Here to Email Shiju Rajan     Edit/Delete Message Reply w/Quote
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

ranjeet
Member
posted April 29, 2000 06:07 AM     Click Here to See the Profile for ranjeet   Click Here to Email ranjeet     Edit/Delete Message Reply w/Quote
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

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.