| ★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum4/HTML/000385.html | Nouvelle recherche | Portail wanayoo |
|
|
DevShed Discussion Forums
![]() MySQL
![]() Querying
|
| next newest topic | next oldest topic |
| Author | Topic: Querying |
|
kunal Junior Member |
How would I check wether a email addy already exists in the database?? the table name is members |
|
Shiju Rajan Member |
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. ------------------ |
|
kunal Junior Member |
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 |
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) GOOD LUCK!! ------------------ |
|
ranjeet Member |
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)
|
|
Shiju Rajan Member |
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. Thank You.
------------------ |
|
ranjeet Member |
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 |
All times are MST (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1997-2000 ngenuity. All rights reserved.
Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.