PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dbarron87
Forum Newbie
Posts: 16 Joined: Wed Apr 20, 2011 8:12 pm
Post
by dbarron87 » Wed May 04, 2011 4:05 pm
hello, hopefully this is in the correct section.
i am wondering how i would retrieve the following forms chosen option
Code: Select all
<FORM METHOD=GET ACTION=ship_detail.php
<select name='myCarrier'>
<option value='dhl'>DHL</option>
<option value='ups'>UPS</option>
<option value='fedex'>Fedex</option>
<option value='mompap'>Mom And Pap</option>
<option value='somepost'>Some Post</option>
</select>
i would luke to receive the chosen option on a page known as detail.php
thanks for your help in advance.
eivind
Forum Commoner
Posts: 28 Joined: Tue Apr 19, 2011 7:57 am
Post
by eivind » Thu May 05, 2011 1:57 am
First of all you miss a '>' on the end of your form tag.
You can retrieve it with $_GET['myCarrier'] on whichever page you chose to set action= to.
dbarron87
Forum Newbie
Posts: 16 Joined: Wed Apr 20, 2011 8:12 pm
Post
by dbarron87 » Thu May 05, 2011 4:22 pm
kunalk wrote: Are you trying to submit the data to detail.php(as per your post) or ship_detail.php (as per your code)?
yes i think that is what i am trying to do, being to detail.php
dbarron87
Forum Newbie
Posts: 16 Joined: Wed Apr 20, 2011 8:12 pm
Post
by dbarron87 » Thu May 05, 2011 4:35 pm
eivind wrote: First of all you miss a '>' on the end of your form tag.
You can retrieve it with $_GET['myCarrier'] on whichever page you chose to set action= to.
This is going to sound silly but i still do not understand. i have read so many types of forms the past 3 weeks i have a complete mental block.
would it just be something like
<? $_GET['myCarrier'] ?>
and how would the script no to put the chosen option in to text for example?
your help is appreciated as it's helping me learn.
many thnaks
eivind
Forum Commoner
Posts: 28 Joined: Tue Apr 19, 2011 7:57 am
Post
by eivind » Mon May 09, 2011 6:03 am
try <? echo $_GET['myCarrier'] ?> and see what comes out
Gopesh
Forum Contributor
Posts: 143 Joined: Fri Dec 24, 2010 12:48 am
Location: India
Post
by Gopesh » Mon May 16, 2011 6:59 am
Hi,this is complete code that gets the values and prints to another page..
Code: Select all
<FORM method="get" action="detail.php">
<select name='myCarrier'>
<option value='dhl'>DHL</option>
<option value='ups'>UPS</option>
<option value='fedex'>Fedex</option>
<option value='mompap'>Mom And Pap</option>
<option value='somepost'>Some Post</option>
</select>
<input type="submit" value="submit" />
</FORM>
The code for detail.php is as follows
Code: Select all
<?php
$name=$_GET['myCarrier'];
echo $name;
?>
Try to use $_POST for passing values.
Hope that it works for u...