I am trying to figure out how to pass "form values" from URL1 to a URL2 thank you page which has an "if" "else if" equation that decides based on a "yes" or "no" radio selection where to direct the user to the resulting URL3.
For example: I need to pass the email value from this field on the URL1 form.
...through this URL2 "thankyou.php" page...
<?php
//echo "<pre>"; print_r($_GET);
if($_GET["inf_option_Areyouahomeowner"] == "226") {
// I prefer to book a phone consultation.
$url = "http://domain.ca/consult-request";
} else {
// Do not qualify.
$url = "http://domain.ca/solar-options";
}
header("Location:".$url);
?>
...then the new form on the resulting page URL3 http://domain.ca/consult-request will have a hidden field containing the "email" field form the original form.
I've tried "as a non-php programmer to use session variables and php echo but no matter what I try the "email value" doesn't make it to URL3.
By the way, URL1 and URL3 are wordpress pages, so if I'm using Session variables I need to know where to put session start etc.
There some very simple example for session:
1.php
<?php
session_start();
$_SESSION['value'] = 123;
echo '<a href="2.php">next</a>';
2.php:
<?php
session_start();
echo '<a href="3.php">next</a>';
3.php:
<?php
session_start();
echo "value:".$_SESSION['value'];
session_destroy();
Okay, so based on the simple example that Philipp suggested and reading other posts, this is what I have so far....
1.php
<?php
session_start();
$_SESSION['inf_field_Email'] = $emailValue;
?>
form field:
<input type='text' class="inputForm" id="inf_field_Email" ``name='inf_field_Email' size='60' placeholder="Enter Valid Email Here" />
2.php
<?php
session_start();
$_SESSION['inf_field_Email'];
?>
3.php
<?php
session_start();
$_SESSION['inf_field_Email'];
?>
form field:
<input name="inf_field_Email" type="hidden" value="<?php echo $_GET['inf_field_Email']; ?>
However, the hidden field is still not being populated on 3.php.