0

I am working on a form site with a pretty traditional php form which emails the data to myself after it is entered then re-directs the user to a html page using the header function.

I was wondering if I could change the header function to redirect to a php page which would display the data that was entered in the form. Is this possible and how do you do it?

2 Answers2

2

You can, but you need to send the data via http GET. For example:

$foo = $_POST['foo'];
$bar = $_POST['bar'];
header('Location: http://example.com/index.php?var1=$foo&var2=$bar');

However, a better solution is to process the submit in the same page, so you can directly display the data:

echo htmlentities($_POST['foo']);
Simone
  • 20,302
  • 14
  • 79
  • 103
2

You can't do it, but you can put the posted data into a $_SESSION variable, then redirect the user.

Pethical
  • 1,472
  • 11
  • 18