代码如下:
PHP
/**
* 在PHP中验证复选框的有效性
*/
$value = 'yes';
echo " 验证数据"; if (isset($_POST['subscribe'])) {
if ($_POST['subscribe'] == $value) {
$subscribed = true;
} else {
$subscribed = false;
print '提交的复选框值无效。';
}
} else {
$subscribed = false;
} if ($subscribed) {
print '验证有效!';
} else {
print '验证无效!';
}
原文链接:https://www.f2er.com/php/25426.html/**
* 在PHP中验证复选框的有效性
*/
$value = 'yes';
echo " 验证数据"; if (isset($_POST['subscribe'])) {
if ($_POST['subscribe'] == $value) {
$subscribed = true;
} else {
$subscribed = false;
print '提交的复选框值无效。';
}
} else {
$subscribed = false;
} if ($subscribed) {
print '验证有效!';
} else {
print '验证无效!';
}