-1

I have a rather larger form and when it submits it posts to the same page as the form and runs the PHP validation.

Basically if all is validated correctly I want to then show a different page with all the information that has been posted on it a sort of report or confirmation allowing the user to print the report. The data in the form is not stored in any database its just emailed off.

What I am having trouble with is retrieving the values as the form action is not going to the report page just itself. I therefore need some advice.

Should I look for a way of changing the form action location with an if i.e. if all valid echo report.php but this would require the user to resubmit the form, or is there a better way?

Your advice would be greatly received.

Mark H
  • 589
  • 2
  • 11
  • 20
  • Beside the fact I see no reason to have validation script the same page where the HTML is, there's a way to do it, yep. You can assign post values to session variables, so they will be present on the next page where the redirection is. On both pages you have to start session on the top. – Royal Bg Aug 19 '13 at 14:18
  • Either store in Session or put data into hidden form fields on the confirm page if you have some reason not to use sessions – Anigel Aug 19 '13 at 14:21

1 Answers1

0

You should probably store your values in Session before redirecting. Then in your other page read them out, and clear them.

See also: PHP Pass Data with Redirect

edit: You may also want to take a look at the Post-Redirect-Get (PRG) pattern. Googling it should bring up some usable examples

Community
  • 1
  • 1
Kippie
  • 3,760
  • 3
  • 23
  • 38