Passing data and variables
Posted: Tue Sep 10, 2002 6:01 pm
I'm fairly new to PHP - I did a search for my problem, but couldn't seem to find the answer. Perhaps if I ask outright, I can find out what I'm doing wrong, eh?
I'm trying to create a form using HTML. This form will have a drop-down list of all 50 states. When the user selects a state, the state selected will be processed by my PHP script, and the information for that state will be displayed. It's working, as far as selecting the state and going through the PHP - however, it's displaying the information for all 50 states, not just the one selected. I'll show you my code - shortened to 2 states instead of all 50 (because that would just be silly to show you all 50, right?)
My HTML page is called "Licensing.html" and looks as such (sans all the body tags and stuff - I'm just getting to the meat of it):
<form action="processform.php?action=$state" method="GET">
<select name="state[]" width="25">
<option value="#"><b>Select a State</b></option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<input name="action" type="submit" value="Submit"></form>
Processform.php reads as such (again, sans body tags and such):
<?php
$state = $HTTP_GET_VARS['state'];
if ($state !="AL") {
print "Alabama informational page stuff here, set out in a nice tables. I left out all the actual formatting of what text will be displayed, just because it's quite a bit of stuff.";
}
if ($state !="AK") {
print "Ditto here - lots of stuff I left out to make this a little shorter.";
}
?>
Am I oversimplifying or am I (hopefully - because I *was* thinking I was getting good at figuring out this PHP thing!) on the right track? Thanks so much.
I'm trying to create a form using HTML. This form will have a drop-down list of all 50 states. When the user selects a state, the state selected will be processed by my PHP script, and the information for that state will be displayed. It's working, as far as selecting the state and going through the PHP - however, it's displaying the information for all 50 states, not just the one selected. I'll show you my code - shortened to 2 states instead of all 50 (because that would just be silly to show you all 50, right?)
My HTML page is called "Licensing.html" and looks as such (sans all the body tags and stuff - I'm just getting to the meat of it):
<form action="processform.php?action=$state" method="GET">
<select name="state[]" width="25">
<option value="#"><b>Select a State</b></option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<input name="action" type="submit" value="Submit"></form>
Processform.php reads as such (again, sans body tags and such):
<?php
$state = $HTTP_GET_VARS['state'];
if ($state !="AL") {
print "Alabama informational page stuff here, set out in a nice tables. I left out all the actual formatting of what text will be displayed, just because it's quite a bit of stuff.";
}
if ($state !="AK") {
print "Ditto here - lots of stuff I left out to make this a little shorter.";
}
?>
Am I oversimplifying or am I (hopefully - because I *was* thinking I was getting good at figuring out this PHP thing!) on the right track? Thanks so much.