I have a multi-step form, let's say for the sake of ease it's 2 steps. First step I want to select a radio button and based on that radio button selection it takes me to a certain page, but I also want that selection stored in a session. I have 2 pages: page1.php
session_start();
if(isset($_POST['post'])) {
if (($_POST['country'] == 'US')) {
header("Location: US_Products.php"); }
elseif (($_POST['country'] == 'CDN')) {
header("Location: CDN_Products.php"); }
else { die("Error"); }
exit;
}
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="USA">USA:</label>
<input type="radio" name="country" value="US">
<label for="CDN">Canada:</label>
<input type="radio" name="country" value="CDN">
<input type="submit" name="post" value="Go To Filter">
</form>
Page2.php (either A or B)
session_start();
$_SESSION['country'] = $_POST['country'];
<?php echo $_SESSION['country']; ?>
The Country choice is not being passed when I have it do this conditional redirect. Is there a problem with session variables and redirects or session variables and PHP_SELF or something?