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

PHP Build a Simple PHP Application Adding a Contact Form Checking the Request Method

Rachel Lee
Rachel Lee
1,611 Points

Where does the submission go?

When a user submits a form and you put all the contact files into one, where does their submission go?

2 Answers

The submission will go to the same file. The action="contact.php" decide where the information will be sent. Since it's sent to the same file the php code will in that file will take it. In the same file you'll have to find out if the method is post or get. When you download files from the server/visit a page the method will be get. But when you submit a form the method is post, since you will then send stuff to the server/submit a form. The php code checks if the form is sent aka method="post" and then it will process the $_GET array with the information sent.

Kevin Korte
Kevin Korte
28,148 Points

It goes to whatever file the form is given in it's action attribute tells it. The form can actually even submit to the same file it's part of.