PHP session variables lost on header redirect using PHP_SELF in the form action

pelaorap

New Member
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\[code\]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="http://stackoverflow.com/questions/3935359/US"><label for="CDN">Canada:</label><input type="radio" name="country" value="http://stackoverflow.com/questions/3935359/CDN"><input type="submit" name="post" value="http://stackoverflow.com/questions/3935359/Go To Filter"></form>\[/code\]Page2.php (either A or B)\[code\]session_start();$_SESSION['country'] = $_POST['country'];<?php echo $_SESSION['country']; ?>\[/code\]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?
 
Back
Top