Forum Moderators: coopster
here is the page with the drop down menu
<html>
<head>
<title>What gallery would you like to view</title>
</head>
<body>
<?php
include ('includes/header.inc');
?>
<form name="form1" method="post" action="displaygallery.php"
enctype="multipart/form-data">
<table border="0" cellpadding="5">
<tr>
<td>What gallery would you like to view?<br>
<em>Example: Weddings</em></td>
<td><select name="displaygallery">
<option value="" selected>Select a location....</option>
<option value="http://www.example.com/gallery/centerpieces/gallery_centerpieces1.php">Center Pieces</option>
<option value="http://www.example.com/gallery/classicdecor/gallery_classicdecor1.php">Classic Decor</option>
<option value="http://www.example.com/gallery/dancefloors/gallery_dancefloors1.php">Dance Floors</option>
<option value="http://www.example.com/gallery/deliverybouquets/gallery_deliverybouquets1.php">Delivery Bouquets</option>
<option value="http://www.example.com/gallery/propsandeffects/gallery_propsandeffects1.php">Props and Effects</option>
<option value="stagedecor">Stage Decor</option>
<option value="themedecor">Theme Decor</option>
<option value="tradeshows">Trade Shows</option>
<option value="weddings">Weddings</option>
</select>
</td>
</tr>
</table>
<br>
<p align="center"><input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Clear Form">
</p>
</form>
</body>
</html>
<?php
include ('includes/footer.inc');
?>
Here is displaygallery.php
<?php
$displaygallery = $_POST['displaygallery'];
echo "Display: $displaygallery<br>";
header("location: $displaygallery");
?>
Any ideas why this would not work? Thanks!
[edited by: coopster at 2:43 pm (utc) on Sep. 22, 2005]
[edit reason] generalized url TOS [webmasterworld.com] [/edit]
As for your error, off the top of my head, I'm guessing your header error is something along the lines of:
Warning: Cannot modify header information - headers already sent by...
This is because of the 2nd line in displaygallery.php
echo "Display: $displaygallery<br>";
With this, you are sending data to the client, and so a header response (of 200 OK most likely) has already been sent. Hence a location: header cannot be added (because that issues a 302 redirect).
Remove the echo... line and see if it works. If it doesn't, I apologise for it is 2 AM here :)
Check the URL in the title bar, because displaygallery.php may be redirecting to a page that does not exist.
You could also // comment out the header("location: $displaygallery"); part, then re-add
echo "Display: $displaygallery";
To make sure $displaygallery is set to a valid URI. From the php website:
"HTTP/1.1 requires an absolute URI as argument to Location: including the scheme, hostname and absolute path, but some clients accept relative URIs."
That solution will work, but only with browsers that have javascript enabled. The rest will see a blank page. To complete the solution chaddsisco could add:
echo("If you are not automatically redirected to $displaygallery, please <a href='$displaygallery'>click here</a>");
Even still, if using the php header function didn't work, chances are the URI set in $displaygallery is wrong. Using the header function to send a 302 redirect has the other advantage that it will automatically redirect even those without javascript enabled.
Although, if you want to go down the javascript route, you could make an onClick event handler for the submit button on the form page... but again you run into trouble when someone has javascript disabled.
Only my .02