I am trying to create a page with a Disclaimer and Agreement in WordPress/PHP.
Disclaimer:
- If users select ‘UK’ from a dropdown, they are sent to an Agreement page.
- If users select any other country, they are sent to an ‘Access Denied’ page.
Agreement:
- If the user clicks “I agree” they are sent to the final stage “Well Done”.
- If the user clicks “Disagree” they are sent to the ‘Access Denied’ page.
I’ve come up with the following, but the select options are not working and I’m not sure how to direct all countries except the UK to an access denied page.
Any ideas what I am doing wrong?
<?php
session_start();
if(!isset($_SESSION['grant_access'])) {
$_SESSION['grant_access'] = âunsetâ;
}
if(isset($_POST['United Kingdom'])) {
$_SESSION['grant_access'] = âpartialsetâ;
}
if($_SESSION['grant_access'] == âpartialsetâ) { ?>
'<p>You are nearly there. Now you must agree.</p>';
<form method="post">
<form method="post">
<input type="submit" value="I Agree" name="agree" />
</form>
<?php
}
if($_SESSION['grant_access'] == âunsetâ) {
?>
<h1>Disclaimer.</h1>
<p>Choose your country.</p>
<form method="submit">
<select>
<option value="Australia" title="Australia">Australia</option>
<option value="France" title="France">France</option>
<option value="United Kingdom" title="United Kingdom">United Kingdom</option>
<option value="United States" title="United States">United States</option>
</select>
<input type="submit" value="Submit">
</form>
<?php
} else {
echo 'Well done.';
} ?>
You don’t have a
name="..."
on your select, so nothing will be submitted there. Thevalue
of the selected option is what’s submited, so you’d need:and