|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How would I check wether a email addy already exists in the database?? the table name is members
|
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
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
|
|
#4
|
||||
|
||||
|
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 |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
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 |
|
#7
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Querying |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|