Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Simple PHP Application Integrating with PayPal HTML Forms

Shane Roth
Shane Roth
5,880 Points

Pass value of flavor from the select box

I have tried to look through the videos to find this. I know I can set a value by $flavor="" but to get the value from the select and pass it to post. I though this was done using php in the form submit redirection. I am obviously confused and can't find the answer in the videos

4 Answers

no, if you are posting your form you would do something like this

<form method="POST" action="process.php">
<select name="select">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<input type="submit" name="go" value="GO" />

in the php do something like this



$select = $_POST['select'];

echo $select;



Have you give your select box a name?

so for example if you had a select box like

<select name="coolbox"> <option value="val1">Option 1</option> <option value="val2">Option 2</option> <option value="val3">Option 3</option> </select>

Then you could get the result in php after you submit the form like so

$select = $_POST['coolbox'];

Shane Roth
Shane Roth
5,880 Points

ok naming the select seems familiar, I need to pass the variable in post right? so I have input=submit action="process.php?flavor=NAMEOFSELECT>


If you want the selection to be appended to the end of the URL, you will need to switch the form method from post to get. Get will send all the form information via the URL. Post will send all form information in the background and not in the URL. If you need the form information in the URL, switch the form method to GET.


then in php just change $_POST to $_GET