可能重复:
Robust, Mature HTML Parser for PHP
这是我心目中的一个设计模型- http://i.imgur.com/ujiLb.jpg。
从每组选项中,只有一个必须被选中,根据复选框的组合,“提交”按钮指向网页。
这两个特性将是
价格(请选择一个)
1-99 100-249 250-499
制造商(请选择一个)
A、B、C
提交按钮
我所能理解的绝对错误的编码是:
//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”等。
发布于 2011-09-22 01:59:35
$_POST是一个数组,而不是一个函数,您需要$_POST['product'];
$product = $_POST["product"]; //note [ and ] instead of ( and )
$price = $_POST["price"];此外,Location不是我所知道的函数,@erisco指出,您需要使用header
if (($product == "A") && ($price == "5")) {
header("Location: a-5-10.html"); // Products matching A, price 5-10 etc
} //also note the closing brace
elseif (($product == "B") && ($price == "5"))
{
header("Location: b-5-10.html"); //Products matching b, price 5-10 etc
} //again, closing brace, not "endif"https://stackoverflow.com/questions/7508609
复制相似问题