PHP - Pass POST variables with header()?

The header function is used to send HTTP response headers back to the user so actually you cannot use it to create request headers :(

One possibility is to use the CURL but I don't think it is worth of what you are doing.


Dan, You could start and store a session in PHP then save the message as a session variable. This saves you from having to transfer the message in an HTTP request.

Manipulating Sessions

//Start the session
session_start();

//Dump your POST variables
$_SESSION['POST'] = $_POST;

//Redirect the user to the next page
header("Location: bar.php");

Now, within bar.php you can access those POST variables by re-initiating the session.

//Start the session
session_start();

//Access your POST variables
$temp = $_SESSION['POST'];

//Unset the useless session variable
unset($_SESSION['POST']);

To read more about sessions, check out: http://php.net/manual/en/function.session-start.php