I am validating a form. Typically, I submit a form to the same page it is on, so if something fails validation, the data I need is already on the right page and I just repopulate the forms fields.
Now I am submitting a form to a different page, that just processes the data. So if something fails validation I want to send all of the POST data back to the form page so I can repopulate the values.
Can someone please explain if it’s possible to send POST data this way and how it can be done.
CURL, for all intents and purposes, is a browser - it can POST data. What you can’t do is use a redirect to send a browser to a page with POST data, that is, you can’t process the data on page2 and send the browser back to page1 with POST data. Do what guido suggested, use the session, or the GET query string.
Ahh but it can…
page 1
start sessions
check to see if bad_data is true
if bad_data = true then get the data from the session variables and display form with data
if bad_data is false then display empty form
page 2
start sessions
obtain the posted data
validate data
if bad…
create session variables containing the posted data
set bad_data (session variable) to true
send back to page 1