Brandon_R Posted July 2, 2009 Share Posted July 2, 2009 I AM very new to PHP and wanting to know how would i go about doing this. I Have a form with a specific amount of options IE A, B, C, D, E. Now i want C to represent Carrot. So If A User Chose C, the php to return , "You Have Chosen Carrot" on the ?do=process page. Any ideas on how to do this. Link to comment https://forums.phpfreaks.com/topic/164471-how-would-i-go-about-accomplishing-form-placement/ Share on other sites More sharing options...
xjasonx Posted July 2, 2009 Share Posted July 2, 2009 <?php if (isset($_GET['fruit'])) { $fruit = $_GET['fruit']; echo "You have chosen ".$fruit."."; } ?> <form method="GET" action="fruit_page.php"> Choose a letter:<select name="fruit"> <option value="Apple">A</option> <option value="Bannana">B</option> <option value="Carrot">C</option> <!-- and so on... --> </select> <input type="submit" value="submit"> </form> Something like that? Link to comment https://forums.phpfreaks.com/topic/164471-how-would-i-go-about-accomplishing-form-placement/#findComment-867616 Share on other sites More sharing options...
Brandon_R Posted July 2, 2009 Author Share Posted July 2, 2009 Yes perfect but is there a way to also return the abbreviation in the php echo also. Something like "You Have Chosen C Which Stands For Carrots". Should of Said That In My First Post Also. Thanks For All Your Help So Far. Link to comment https://forums.phpfreaks.com/topic/164471-how-would-i-go-about-accomplishing-form-placement/#findComment-867618 Share on other sites More sharing options...
xjasonx Posted July 2, 2009 Share Posted July 2, 2009 <?php //changing it to post if (isset($_POST['fruit'])) { $fruit = $_POST['fruit']; $fruits = explode(":",$fruit); echo "You have chosen ".$fruits[0]." which stands for ".$fruits[1]."."; } ?> <form method="POST" action="fruit_page.php"> Choose a letter:<select name="fruit"> <option value="A:Apple">A</option> <option value="B:Bannana">B</option> <option value="C:Carrot">C</option> <!-- and so on... --> </select> <input type="submit" value="submit"> </form> I've never done anything like that before, but it seems like that would work. I'm sure there are better ways to do it. Link to comment https://forums.phpfreaks.com/topic/164471-how-would-i-go-about-accomplishing-form-placement/#findComment-867625 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.