我想创建一个复选框,当用户检查并提交其显示的特定元素时。
这是admin.php
中的选择表单 <form action="/html/codes/html_form_handler.cfm" method="get">
<input type="radio" name="page_type" value="adv" > advertisement<br>
<input type="radio" name="page_type" value="ann" > announcement<br>
<input type="radio" name="page_type" value="pic" > picture <br>
<input type="submit" value="Submit">
</form>
,所选部分将显示在user.php中。每个选项都有自己的php文件,所以我有3个文件adv.php,ann.php和pic.php。并使用<?php include 'adv.php'; ?>
在user.php中显示
任何建议怎么做??
答案 0 :(得分:0)
像这样更新您的表单;
<form action="/html/codes/html_form_handler.cfm" method="get">
<input type="radio" name="page_type" value="adv" > advertisement<br>
<input type="radio" name="page_type" value="ann" > announcement<br>
<input type="radio" name="page_type" value="pic" > picture <br>
<input type="submit" value="Submit">
</form>
在后端;
$pages = array ("adv", "ann", "pic");
$page_type = $_GET["page_type"];
// Validate page type
if (in_array($page_type, $pages)) {
include $page_type . ".php";
} else {
die("Invalid page type");
}