I made a simple form in WordPress as follows:
<form action="../process.php" method="post" name="myForm">
vol_single <input id="vol_single" type="text" name="vol_single" />
rate_single <input id="rate_single" type="text" name="rate_single" />
<input type="submit" value="Submit" /></form>
and here is process.php:
<?php
session_start();
$vol_single = $_POST['vol_single'];
$rate_single = $_POST['rate_single'];
$rate_total=12*($vol_single*$rate_single);
//Redirects to the specified page
header("Location: http://...");
exit();
?>
I’m trying to display the calculated value on the redirected page in WordPress. I have tried this:
[insert_php]
echo 'total rate:';
echo $rate_total;
[/insert_php]
It does not display any values. Could anyone help?
You wouldn’t have access to the variables after a redirect. The life time of your variables end after the execution of each script.
To achieve such, you could either store the variables inside sessions or append them to the end of the redirect target and access them from $_GET superglobals on the new page like so:
You can find a quick introduction to sessions here.