The task:
- I want to pass a input variable (lets call it $email) from a form (form action = page2.php) with post method from page1.php to page3.php
The description:
- Form action goes to page2.php, which then redirects to page3.php instantly. page2.php is just tons of php executions that processes the form from page1.php.
The problem:
- I get the variable on page2.php but before anything is done with $email, the page redirects to page3.php and i lose the data. I tried making a form on page2.php that posts the data onward with autosubmission, but it doesnt work. I tried to put the form on top of page2.php and sleep the rest of the code for a small amount of time, but it doesent work. I tried to execute the other part of the code in an if statement
if($_SERVER['REQUEST_METHOD'] == "POST")and it didnt work either.
The code:
Nothing special about the code really. page1.php contains a form, page2.php contains some includes which then redirects and page3.php is the landing page.
page1.php:
<form action="page2.php" method="POST" id="form1"> <table> <tr> <td>E-Mail:</td> <td><input type="text" name="email" id="email"></td> </tr> <input id="submitBtn" style="margin-left: 120px;"> </table> </form>
The summary:
- Basicaly im looking for something, that would pass the $email variable from page2.php to page3.php before redirection.
* UPDATE * I have been struggeling with this for 2 straight days, now i accualy stumbled across a solution. If anyone has the same problem or is wondering, what i did was, i used $_SESSION.
On page2.php where the form was directed i used this code on top of the page:
$var_value = $_POST['email'];
$_SESSION['varname'] = $var_value;
On page3.php i then called the session variable like this:
$var_value = $_SESSION['varname'];
echo $var_value;