$php_mysql$ Posted August 19, 2011 Share Posted August 19, 2011 friends how can i store email id of user in 2 tables? in my table one user can post same email many time, but in my tbl2 i want to make it check if email exist i also make the row unique in tbl2 for email function insertData($postData) { //trying to check if email not exist in tbl2 then store the email else go below and keep adding same email as many times,, the function ifEmailExistschecks for existence of emails if(!ifEmailExists($postData['email'])){ $sql = " INSERT INTO tbl2 SET email = '".$postData['email']."' "; executeSql($sql); }else{ //in below same email can be store as many times $sql = " INSERT INTO tbl1 SET title = '".$postData['title']."', image = '', description = '".$postData['description']."', time = '".time()."' "; executeSql($sql); }else{ $sql = " INSERT INTO tbl SET title = '".$postData['title']."', image = '".$resize_rename."', description = '".$postData['description']."', time = '".time()."' "; executeSql($sql); } } this code stores the email for first time but when i try to enter data again i get Duplicate entry '[email protected]' for key 'email' what is the solution for this? Link to comment https://forums.phpfreaks.com/topic/245230-store-emails-in-two-different-tables/ Share on other sites More sharing options...
$php_mysql$ Posted August 19, 2011 Author Share Posted August 19, 2011 lol this time solved :-D issue was the else i should not have used that :-) Link to comment https://forums.phpfreaks.com/topic/245230-store-emails-in-two-different-tables/#findComment-1259554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.