我正在尝试使用WordPress / PHP中的免责声明和协议创建一个页面。
免责声明:
协议:
我已经提出以下内容,但选择选项不起作用,我不确定如何将除英国以外的所有国家/地区指向拒绝访问页面。
任何想法我做错了什么?
<?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.';
} ?>
答案 0 :(得分:1)
您的选择中没有name="..."
,因此不会在此处提交任何内容。所选选项的value
是提交的内容,因此您需要:
<select name="country">
<option value="United Kingdom" />UK
...
</select>
和
if(isset($_POST['country']) && ($_POST['country'] == 'United Kingdom')) {
...
}