want selected option from html form to link to a file
Posted: Fri May 09, 2008 1:14 pm
Hi. This is probably a baby question but please help me. I have an html file that has a form for choosing a city from a drop down list of states/cities. When the city(option) is chosen, say for example, Phoenix, I want the php file to link to a html file Phoenix.html. I don't understand how to use the php file to take the information from the form, and process it, say, using an IF statement to link it to a different file (depending on the result of the IF statement). I highlighted the area that I think I need code. Any help will be appreciated. Thanks.
states.html file:
choose_family_city.php file:
states.html file:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang="en" lang = "en">
<head>
<meta http-equiv = "content-type" content = "text/html; charset=iso-8859-1">
<title> Select State And City </title>
</head>
<body>
<form action = "choose_family_city.php" method = "post">
<p><b>State and City: <select name = "city" size = "1"></b>
<optgroup label = "Arizona">
<option>Phoenix</option>
</optgroup>
</select></p>
<div align = "center"> <input type = "submit" name = "submit" value = "Find " /> </div>>
</form>
</body>
</html>
Code: Select all
<html>
<body>
<?php
$page_title = 'Family Cities';
require(states.html);
$city = $_POST['city'];
if($city == 'Phoenix'){
[color=#FF0000]//what would go here to open Phoenix.html???[/color] }
?>
</body>
</html>