Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
by fawadmz » Wed Nov 21, 2012 12:45 am
Hello i have two pages. one have a HTML form lets say form.php . this form sends value of a drop down list (select box) to another page called getdata.php .
i can do it with other html elements but not with select box.
Would be thankful for help
-
fawadmz
- New php-forum User

-
- Posts: 4
- Joined: Wed Nov 21, 2012 12:15 am
by simplypixie » Wed Nov 21, 2012 4:47 am
Does the select allow for multiple selects? Also what is the code for your form and on the getdata.php page so we can see what you are doing (or doing wrong)?
-

simplypixie
- php-forum Active User

-
- Posts: 289
- Joined: Sun Dec 11, 2011 12:51 am
- Location: Shrewsbury, Shropshire
-
by seandisanti » Fri Nov 23, 2012 2:36 pm
just make sure you're specifying values on your options and a name attribute on your select, and then it will be passed as $_POST['select_name'] or $_GET['select_name']
-
seandisanti
- php-forum Fan User

-
- Posts: 679
- Joined: Mon Oct 01, 2012 12:32 pm
by fawadmz » Sun Nov 25, 2012 12:58 am
Lets see if i have in form.php
<select name="search_by" >
<option value="user_name" >User Name</option>
<option value="user_id" >User Id</option>
</select>
in form.php if i want to know what value a user have selected from available options
-
fawadmz
- New php-forum User

-
- Posts: 4
- Joined: Wed Nov 21, 2012 12:15 am
by simplypixie » Sun Nov 25, 2012 1:19 am
You do it exactly the same way as you do with your other form elements (using the value posted from the form referencing the name of the form element):
- Code: Select all
<?php
$search_by = $_POST['search_by'];
?>
-

simplypixie
- php-forum Active User

-
- Posts: 289
- Joined: Sun Dec 11, 2011 12:51 am
- Location: Shrewsbury, Shropshire
-
Return to PHP coding => General
Who is online
Users browsing this forum: Strider64 and 1 guest