Jump to content

store emails in two different tables


$php_mysql$

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.