shibbi3 Posted October 19, 2006 Share Posted October 19, 2006 hi everyone,I am having trouble integrating the select menu and php. I am not sure how to access the selected valueCan anyone tell me what is wrong with this code?[code]<form method="post" action="test.php" enctype="multipart/form-data"> <select name="about"> <option selected="selected">General</option> <option>Lures</option> <option>Sales</option> <option>Other</option> </select></form><?php $selected = $_POST['about']; echo $selected;?>[/code]shouldnt that echo the selected value? Quote Link to comment https://forums.phpfreaks.com/topic/24444-select-menu-and-php/ Share on other sites More sharing options...
HuggieBear Posted October 19, 2006 Share Posted October 19, 2006 You're not submitting the form!Try this:[code]<form method="post" action="test.php" enctype="multipart/form-data"> <select name="about"> <option selected="selected">General</option> <option>Lures</option> <option>Sales</option> <option>Other</option> </select> <input type="submit" name="submit" value="submit"></form><?php $selected = $_POST['about']; echo $selected;?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24444-select-menu-and-php/#findComment-111283 Share on other sites More sharing options...
Orio Posted October 19, 2006 Share Posted October 19, 2006 In PHP, you need to send the information to the server (by clicking submit for example) and then the server can output/do what ever you want.So, you need to have the form (in form.htm for example):[code]<form method="post" action="test.php" enctype="multipart/form-data"> <select name="about"> <option selected="selected">General</option> <option>Lures</option> <option>Sales</option> <option>Other</option> </select><input type="submit"></form>[/code]And then the output comes from test.php, the form's action:[code]<?php $selected = $_POST['about']; echo $selected;?>[/code]You need PHP to be installed on your server of course...Hope it helps, Orio. Quote Link to comment https://forums.phpfreaks.com/topic/24444-select-menu-and-php/#findComment-111287 Share on other sites More sharing options...
stb74 Posted October 19, 2006 Share Posted October 19, 2006 Is this what you need<form method="post" action="" enctype="multipart/form-data"> <select name="about"> <option selected="selected">General</option> <option>Lures</option> <option>Sales</option> <option>Other</option> [color=red]<input type="submit" value="Go" name="submit">[/color] </select></form><?php $selected = $_POST['about']; echo $selected;?> Quote Link to comment https://forums.phpfreaks.com/topic/24444-select-menu-and-php/#findComment-111288 Share on other sites More sharing options...
shibbi3 Posted October 19, 2006 Author Share Posted October 19, 2006 THANK YOU!!!!!!I needed both the submit button and the values for the select menu for it to work.was a silly mistake :STHANK YOU AGAIN!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/24444-select-menu-and-php/#findComment-111289 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.