Possible Duplicate:
Robust, Mature HTML P开发者_StackOverflowarser for PHP Help coding an HTML Form
This is a mockup of design that I have in mind - http://i.imgur.com/ujiLb.jpg
From each set of options, only 1 must be checked and depending on the combination of checked boxes the 'submit' button directs to a webpage.
The two features will be
Price(Please choose one)
1-99 100-249 250-499
Manufacturer(Please choose one)
A B C
[SUBMIT BUTTON]
The coding that I can understand which is definitely wrong is:
//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>
And in search.php, something like ...
<?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
?>
EDIT as per OP's comments, the request is not being redirected to "b-5-10.html" or "a-5-10.html" etc.
$_POST
is an array, not a function, you want $_POST['product'];
$product = $_POST["product"]; //note [ and ] instead of ( and )
$price = $_POST["price"];
Also Location
is not a function that I am aware of as @erisco pointed out you need to use 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"
精彩评论