Forum Moderators: coopster
I have successfully been able to build my list, at least getting the option values to appear in a drop down list.
The issue I have is getting my menu to redirect my users based on their selection. the sample I have used simply echoes the selection.
Any thoughts on how to redirect my users?
Here is what I currently use...
<select id="list">
<OPTION value="#"> Select a Store
<OPTION value="store100.php" >Store100.com
</SELECT>
On selection...they were redirected using the following...
<input type="button" value="Go!" onclick="location.href=document.getElementById('list').value" />
As some change periodically, as I add new/delete old, I want this list to be dynamically generated.
Here is my php code:
$query = "SELECT * FROM Stores WHERE status = 'active' ORDER BY storename";
$result = mysql_query($query)
or die ("Couldn't execute query-come on now!");
/* create form containing selection list */
echo "<form action='processform.php' method='POST'>
<select name='storename'>\n";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<option value='$storename'>$storename\n";
}
echo "</select>\n";
echo "<input type='submit' value='Select Type of Pet'>
</form>\n";
?>
</body></html>
I think my issue is in processform.php which does the following:
<?php
/* Script name: processform.php
* Description: Script displays all the information passed
* from a form.
*/
echo "<html>
<head><title>Customer Address</title></head>
<body>";
foreach ($_POST as $field => $value)
{
echo "$field = $value<br>";
}
?>
</body></html>
Any ideas on how to modify process form to redirect to the url designated?
Thanks!
Thanks! I was able to verify your solution is what I need to implement - however, I cannot seem to get the file to recognize the database field as my destination...
here is what I got (this works!)
header("Location: destination");
but here is what I want:
header("Location: $program");
$program represents the destination page that is dynamic
Thanks!