tags:

views:

58

answers:

4

I have a php page that has a form that asks for an e-mail. When you press the send button, it gets to another php page, which gets the form data and does its stuff. I need to then be able to go back to the old page (the one that contained the form) and give it some data so that it will be able to change itself and say "You've sent your e-mail successfully, and will not display the form. How do I do it?

+1  A: 

Sessions probably

http://us2.php.net/manual/en/book.session.php

Devin Ceartas
A: 

You can either use sessions or cookies, to not depend on the URL cookies have always to be enabled.

Check the PHP Manual (Sessions and Cookies).

Alix Axel
A: 

Options:

1) Set a cookie (or use a session variable, which is kind of the same thing)

2) Use a separate thank-you page. After you've processed the form, redirect to http://www.mysite.com/thankyou

3) Process the form on the same page as itself. If your form is at http://www.mysite.com/myform, then at the top of that page have a little

if ($_POST)
  // process form
  // display thank you
else
  // display form

Good luck!

Summer
A: 

If the user is just seeing data that they've entered anyway, you can just use hidden form fields:

<input type="hidden" id="lang" name="lang" value="en" />

That way you can continue to POST new forms and pass the data down the lane. That's the easiest thing to do without having to write a single extra line of PHP code.

You could also store each section in a database and save each section as-added. That would give you the added benefit of having partial data in the case of a browser crash or whatever, depending on how many parts your form is. You could then pass just an ID to the DB table row and retrieve the data for display.

Jough Dempsey