1
可能重复:
Robust, Mature HTML Parser for PHP
Help coding an HTML FormPHP表单设计帮助
这是设计的样机,我在心中 - http://i.imgur.com/ujiLb.jpg
从每组选项,只有1个必须被检查,并且取决于被选中的框的组合,“提交”按钮指向a 网页。
两个特点将是
价格(请选择一个)
1-99 100-249 250-499
制造商(请选择一个)
ABC
[SUBMIT BUTTON]
我可以编码了解哪些是绝对错误的是:
//search page
...
<form action='search.php' method='post'>
<input type=radio name=product value='a'>A?</input>
<input type=radio name=product value='b'>B?</input>
<input type=radio name=product value='c'>C?</input>
<br>
<input type=radio name=price value='5'>5-10?</input>
<input type=radio name=price value='10'>11-15?</input>
<input type=radio name=price value='other'>15+?</input>
... </form>
而且在search.php中,像...
<?php
$product = $_POST("product");
$price = $_POST("price");
...
if (($product == "A") && ($price == "5")) {
Location("a-5-10.html"); // Products matching A, price 5-10 etc
elseif (($product == "B") && ($price == "5")) {
Location("b-5-10.html"); //Products matching b, price 5-10 etc
....
endif
?>
编辑按OP的评论, 请求不被重定向到“B-5 -10.html”或 “A-5-10.html” 等
谢谢,这确实清除了很多关于我的功能。对于搜索页面本身,您能否告诉我如何编写提交按钮请求? – user958098
您只需要在表单中输入,并添加一个“搜索”按钮 – tobyodavies
谢谢!当我在search.php中添加以下内容并单击搜索时,它仅显示我search.php上的代码 '<?php $ product = $ _POST [“product”]; $ price = $ _POST [“price”]; if((product $“a”)&&($ price ==“5”)){ header(“Location:a-5-10.html”); //产品匹配A,价格5-10等 } //还要注意大括号 elseif((产品==“B”)&&($价格==“5”)) { header(“Location :b-5-10.html“); //产品匹配b,价格5-10等 } //关闭大括号,不是“endif” ?>' – user958098