Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Ben Bastow
24,657 PointsUsing $POST to send the same form data to two different files
Hello!
I am wondering how can i use the data I am getting from my form and then send it using $_POST to two different php files?
Thanks in advance
Ben
1 Answer
thomascawthorn
22,986 PointsHey Ben,
Submitting a form submits a request to a single URL. There's no way (at least that I've heard of) to submit a form to two different files simultaneously.
It sounds like your best bet is to submit the form to a single file/page and handle any further requests on that page.
You could also use javascript to run multiple ajax requests when the form submits.
Hope this helps!
Tom
Kevin Korte
28,149 PointsKevin Korte
28,149 PointsI think you're absolutely right. The form will have to be sent to one location, from there you can have your logic to do as you want.