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

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

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']);

1 Comment

This is working, when the user did not post an arbitary length of data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.