Jump to content

Insert into 3 tables using php.


zodiac

Recommended Posts

Hey, i hope someone cam help me here.

I am try to insert data from a register page into 3 tables in an access database, but i am unsure on how to do this. I have managed to insert into 1 but dont know what to change to get it to send the other data frpm the form into the other 2 tables at the same time.

 

Hope you can help me.

 

Zodiac

Link to comment
Share on other sites

This is what i am working with at the moment, but im not sure if this is the correct way of doing it. I have just tried to do 3 seperate inserts.

As you can see i have been commenting the code out to try and see if different things work.

 

try
//{	$adoCon->Execute   //query to put data from textboxes to the database table
//(	"INSERT INTO User
//(Etitle, Esurname, Eforename, Jobtitle, Areacoverage, EmployeeEmail)
//VALUES
//('$lsTitle', '$Forename', '$Surname', '$JobTitle', '$AreaCoverage', '$txtEmail');"
//);
//}
//catch(Exception $e)				//catch error
//{	echo 'Sorry - There was a problem with adding the data to the database.<br />';
//}


{	$adoCon->Execute   //query to put data from textboxes to the database table
	(	"INSERT INTO [user type]
		(Usertype)
		VALUES
		('$UserType');"
	);
}
	catch(Exception $e)				//catch error
{	echo 'Sorry - There was a problem with adding the data to the database.<br />';
}

{	
	$adoCon->Execute   //query to put data from textboxes to the database table
	(	"INSERT INTO Login
		(Eforename, Esurname, Eusername, Epassword)
		VALUES
		('$Forename', '$Surname', '$Username', '$txtPassword');"
	);
}
	catch(Exception $e)				//catch error
	{	echo 'Sorry - There was a problem with adding the data to the database.<br />';
		}
	code]

Link to comment
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.