I'm not sure what I'm doing wrong here, but after a selection is made in the dropdown from the first "if unset" if, the dropdown still shows up above the the new if's output.
Once a selection is made, it should go to "ukset" or "uknotset" and not show the dropdown again.
Any idea what I am doing wrong?
<?php
session_start();
// if unset
if(!isset($_SESSION['grant_access'])) {$_SESSION['grant_access'] = 'unset';}
if($_SESSION['grant_access'] == 'unset') {
echo '<p>Make your choice</p>';
echo '<form action="" onchange="this.submit()" method="post">';
echo '<select name="thecountry">';
echo '<option>Choose</option>';
echo '<option value="hello">Hello</option>';
echo '<option value="goodbye">Goodbye</option>';
echo '<option value="unsure">Unsure</option>';
echo '</select>';
echo '</form>';
}
// if UK is set
if(isset($_POST['thecountry']) && ($_POST['thecountry'] == 'hello')) {$_SESSION['grant_access'] = 'ukset';}
if($_SESSION['grant_access'] == 'ukset') {
echo 'welcome';
}
// if UK is not set
if(isset($_POST['thecountry']) && ($_POST['thecountry'] !== 'hello')) {$_SESSION['grant_access'] = 'uknotset';}
if($_SESSION['grant_access'] == 'uknotset') {
echo 'access denied';
}
?>