【发布时间】:2012-04-13 12:46:18
【问题描述】:
我从 simplemodal 的代码开始,并根据我的需要进行了修改。这出奇的顺利。我遇到的最后一个问题是要发布一些单选按钮。我将跳过我认为不必要的代码块,只显示我认为相关的内容。我已经从 php.net 尝试了几十种解决方案,但似乎没有任何效果。
HTML
<label for='PayPlatform'>Are you willing to pay for a trading platform?</label>
<input type='radio' name='PayPlatform' value='Yes' tabindex='1001' />Yes
<input type='radio' name='PayPlatform' value='No' tabindex='1002' />No
这是我无法获得值的地方,我的尝试在下面的代码块中有两次尝试,当然它们不是同时尝试的。
else if ($action == "send") {
// other elements form values are retrieved fine, just not the below
$PayPlatform = isset($_POST['PayPlatform']) ? ' checked="checked"' : "";
//the ternary above just submits 'checked="checked" no matter which radio is checked
//another attempt
$PayPlatform = isset($_POST["PayPlatform"]);
//this just submits "1" weather yes or no is checked
$token = isset($_POST["token"]) ? $_POST["token"] : "";
// make sure the token matches
if ($token === smcf_token($to)) {
smcf_send($name, $email, $subject, $phone, $message, $PayPlatform);
echo "Your message was successfully sent, you can close this window";
}
else {
echo "Unfortunately, your message could not be verified.";
}
}
【问题讨论】:
-
var_dump($_POST) 是你的朋友
-
@sdjuan - 我确实转储了 $_POST,它为我检查是的每个值显示“是”,但我无法让它提交是...见下文
-
你能发布你的 var_dump 吗?也许这将有助于解决这个问题。嗯,没关系,我认为 Corbin 是对的。
标签: php post radio-button