【发布时间】:2016-07-14 09:29:00
【问题描述】:
我知道我的查询有很好的记录,但我仍然不确定是否有人可以在这里权衡:我有一个下拉字段“html”或“plain”。
见代码:
$mail_format = 0;
if (isset($_POST['mformat'])) {
$form_is_submitted = true;
if ($mail_format == 'plain' || $mail_format == 'html') {
$clean['mformat'] = $_POST['mformat'];
} else {
$errors['mformat'] = '***You have not ticked a format***';
$errors_detected = true;
}
if(isset($errors['mformat'])) {
$mformat_2 = $errors['mformat'];
} else {
$mformat_2 = '';
}
if (isset($clean['mformat'])) {
$mail_format = $clean['mformat'];
} else {
$mail_format = '';
}
<label for="mform">Mail format</label>
<select name="mformat" id="mform">
<option value="plain">Plain text</option>
<option value="html">HTML</option>
</select>
如果用户没有勾选格式,我如何在上面的消息字段旁边注册错误?同样,如果他们确实勾选了格式但其他字段错误,我如何让它重新显示到用户选择的选项的表单?
提前致谢。
【问题讨论】:
-
你没有在 post 方法中使用
<form>标签吗? -
是的,确实我正在使用带有 post 方法的表单标签返回 $ server 全局数组,但我认为我会忽略所有这些并获取需要配置的代码......跨度>