Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.