Posted by fiziwig on 03/31/06 06:27
I use a dropdown for my navigation bar in one of my sites. The code
looks like this:
Navbar has the form:
<form action="redirect.php" method="GET">
<select name="pg">
<option value="0">- Start Here -
<option value="1">Home
<option value="2">Login
<option value="3">Search
<option value="4">Browse by Author
<option value="5">Browse by Title
<option value="7">Browse by Publication
<option value="8">Database Add or Change
<option value="6">Edit Membership Info
<option value="9">Register
<option value="10">Help
<option value="11">Contact Us
</select>
<input type="submit" value=" GO ">
</form>
redirect.php uses it this way:
if (isset($_GET['pg'])) {
$page=$_GET['pg'];
}
switch ($page) {
case 0 :
case 1 : $goto='somepage.php'; break; // home
case 2 : $goto='somepage.php'; break; // login
case 3 : $goto='somepage.php'; break; // search
case 4 : $goto='somepage.php'; break; // browse author
case 5 : $goto='somepage.php'; break; // browse title
case 6 : $goto='somepage.php'; break; // edit membership
case 7 : $goto='somepage.php'; break; // Browse by publication
case 8 : $goto='somepage.php'; break; // database update
case 9 : $goto='somepage.php'; break; // register
case 10 : $goto='somepage.php'; break; // Help
case 11 : $goto='somepage.php'; break; // Contact
case 12 : $goto='somepage.php'; break; // Logout
case 13 : $goto='somepage.php?ak='.$extra; break;
case 14 : $goto='somepage.php?ak='.$extra; break;
case 15 : $goto='somepage.php?tk='.$extra; break;
}
$url='http://' . $_SERVER['HTTP_HOST'] .
dirname($_SERVER['PHP_SELF']);
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')){
$url = substr($url,0,-1); // chop off any slash
}
$url .= '/'.$goto;
header("location: $url"); // bail out to the redirect page
exit(); // and stop executing this script
}
Go ye and do likewise.
--gary
[Back to original message]
|