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
https://forums.phpfreaks.com/topic/72639-insert-into-3-tables-using-php/
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]

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.