Dark57 Posted April 9, 2010 Share Posted April 9, 2010 So I'm trying to see if an email is already registered before letting someone continue with the registration process to stop multiple accounts being linked to the same email. I'm not sure how to do this but I was wondering if there is a way to go through the database looking for a specific email? I'm sure there is I just don't know how to do it. Link to comment https://forums.phpfreaks.com/topic/198175-comparing-entered-information-to-an-existing-entry/ Share on other sites More sharing options...
the182guy Posted April 9, 2010 Share Posted April 9, 2010 Well you can check if an email already exists like this (assuming you have a table that stores the email) $targetEmail = '[email protected]'; // or get from $_POST ? $sql = "SELECT COUNT(*) FROM mytable WHERE email = '$targetEmail'"; $result = mysql_query($sql); if($result) { if(mysql_num_rows($result) == 1) { $count = (int)mysql_result($result, 0, 0); if($count > 0) { // email already exists } } } Link to comment https://forums.phpfreaks.com/topic/198175-comparing-entered-information-to-an-existing-entry/#findComment-1039794 Share on other sites More sharing options...
Dark57 Posted April 9, 2010 Author Share Posted April 9, 2010 Ok. I think I see what I have to do. $targetemail = $_POST['myemail']; $sql = "SELECT COUNT(*) FROM $tbl_name WHERE email = '$targetemail' LIMIT"; if (isset(!$sql)) { //continue registration? } else { //email error message? } Is that a rough idea of what I should be doing? And also what does LIMIT do? Link to comment https://forums.phpfreaks.com/topic/198175-comparing-entered-information-to-an-existing-entry/#findComment-1039799 Share on other sites More sharing options...
the182guy Posted April 9, 2010 Share Posted April 9, 2010 See my editted post, I submitted it by accident, LIMIT should not be used in this case. Link to comment https://forums.phpfreaks.com/topic/198175-comparing-entered-information-to-an-existing-entry/#findComment-1039801 Share on other sites More sharing options...
Dark57 Posted April 9, 2010 Author Share Posted April 9, 2010 Oh, ok. The *, does that have to be changed to a variable or is that good? Link to comment https://forums.phpfreaks.com/topic/198175-comparing-entered-information-to-an-existing-entry/#findComment-1039802 Share on other sites More sharing options...
the182guy Posted April 9, 2010 Share Posted April 9, 2010 Oh, ok. The *, does that have to be changed to a variable or is that good? It's normal to use the * there. You don't need to change it. Link to comment https://forums.phpfreaks.com/topic/198175-comparing-entered-information-to-an-existing-entry/#findComment-1039809 Share on other sites More sharing options...
Dark57 Posted April 9, 2010 Author Share Posted April 9, 2010 Ok, thanks a lot. Without you guys I'd be so lost Link to comment https://forums.phpfreaks.com/topic/198175-comparing-entered-information-to-an-existing-entry/#findComment-1039814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.