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

Alex Watts
Alex Watts
8,396 Points

Handling multiple forms across a website in PHP

Hello,

I have a website which includes multiple forms across different webpages. I would like to have a single page called process.php that validates the users input and sends an email (all in that one page). How can I send an error message back to where the form is submitted? My script successfully validates the input but if that data is incorrect how can I send the error message back to where it was submitted and then display it. My first attempt was to have the PHP script in the page where the form was, but I have over three forms! This is then difficult to update as I have to go to each page and change the code.

Thank you in advance!

Chris Davis
Chris Davis
16,280 Points

I'm sorry man, i'm not really sure. On a site that i manage which has many forms, i have a process.php file for each form. I'm afraid that if i try to bundle everything into a single php file it can become unmanageable.

Here is a thread i found on the topic http://stackoverflow.com/questions/10459012/multiple-forms-and-one-processing-page

Hope that helps :thumbsup: