Kodak07 Posted April 25, 2007 Share Posted April 25, 2007 I want to put the value of my drop down list into a PHP $_GET variable: This is the html code <form action="insert.php" method="post"> <select name="users"> <option value="user1">user1</option> <option value="user2">user2</option> <option value="user3">user3</option> how do i put the value into $_GET["q"] and pass it to my php page that runs a query? Link to comment https://forums.phpfreaks.com/topic/48541-solved-putting-a-html-variable-into-_get/ Share on other sites More sharing options...
kenrbnsn Posted April 25, 2007 Share Posted April 25, 2007 When the form is submitted all the values from the form will be, in this case, in the $_POST superglobal array. The value selected from the dropdown list will be in $_POST['users']. Once your script starts, you can do anything you want with it. Why are you asking about $_GET["q"]? Ken Link to comment https://forums.phpfreaks.com/topic/48541-solved-putting-a-html-variable-into-_get/#findComment-237639 Share on other sites More sharing options...
Kodak07 Posted April 25, 2007 Author Share Posted April 25, 2007 the $_POST["q"] part is what i called the variable on the other page. So the variable is stored in the arrray and associated with the name of whatever the name of the form control is, if that makes sense? Link to comment https://forums.phpfreaks.com/topic/48541-solved-putting-a-html-variable-into-_get/#findComment-237645 Share on other sites More sharing options...
kenrbnsn Posted April 25, 2007 Share Posted April 25, 2007 Can you post some of the code you're working with between tags? Seeing your code, may make it easier to figure out what you want. Ken Link to comment https://forums.phpfreaks.com/topic/48541-solved-putting-a-html-variable-into-_get/#findComment-237655 Share on other sites More sharing options...
AndyB Posted April 25, 2007 Share Posted April 25, 2007 Logically, to get the 'q' in the $_GET array, edit your form as below: <form action="insert.php" method="get"> <select name="q"> <option value="user1">user1</option> <option value="user2">user2</option> <option value="user3">user3</option> </select> <input type="submit" value="Go"/> </form> Link to comment https://forums.phpfreaks.com/topic/48541-solved-putting-a-html-variable-into-_get/#findComment-237689 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.