将数据发布到当前页面进行验证,并将发布数据传递到第二页进行处理

I have a situation where I have a form on multiple pages that all post their data to a "thank you" page with code that emails the data to me.

Validation failure I need to do php validation on the page the form is on so that if one of the required fields isn't filled in, I can reload the page with the form fields pre-populated with the info the user input.

Validation success If the validation passes I then need to send the data to the "thank you" page to be emailed to me

I have no idea if this is possible. If there's a better way of accomplishing what I'm trying to do, suggestions are welcome.

Better explanation?

  • domain.com/page1 - form on page
  • domain.com/page2 - form on page
  • domain.com/page3 - form on page
  • domain.com/page4 - form on page

All forms currently post to domain.com/thank-you where data is sent via email using phpmailer

PHP validation must happen on pages with forms. Data must then be sent to domain.com/thank-you so that it can be sent via email.