Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-31-2009, 03:04 PM   #1
Senior Member
Registered: Oct 2001
Location: Bristol UK
Distribution: Slackware Ubuntu
Posts: 1,053

Rep: Reputation: 42
Web form retrieve <select><option> with PHP

I am either very stupid or very very tired but I cannot quite understand how to retrieve data from a web form if the data is in a <select> box. The data is being sent via email.

PHP is VERY new to me. I have managed to understand this syntax :

$surname = $_POST['surname']

and this has led to :

$body = "First Name:$firstname\n surname:$surname\n E-Mail:$email\n address:\n$address\n" ;

My web form is emailed perfectly. I need now to get data from :


I don't understand how to refer to this in my php. It's almost as though <select> should have an id. <select name="choice"> ??

Hmmm! I am really tired. I don't know if my question even makes sense. I love it when I am completely in the dark.

Thanks in advance!!!!!
Old 08-01-2009, 01:08 AM   #2
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You need to add the name attribute then the selected item will be returned in the $_POST array with the name being the key.
Old 08-01-2009, 03:18 AM   #3
Senior Member
Registered: Oct 2001
Location: Bristol UK
Distribution: Slackware Ubuntu
Posts: 1,053

Original Poster
Rep: Reputation: 42
I reread my post this morning and kicked myself (twice.) I had answered myself. Many thanks graemef : your response confirmed everything for me. It works!!

Now I need to understand how to report an error if a registrant does not tick a specific box.

Simple things sometimes takes massive leaps of understanding.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
doc automation : retrieve information from microsoft word form or excel with scripts gink_oh Linux - Newbie 1 11-17-2008 05:29 AM
how to show results of a php query from a form on the main form texmansru47 Programming 2 06-27-2008 01:26 PM
multiple-select form validation with javascript baikonur Programming 7 10-12-2007 07:28 AM
PHP: build query from form entry, then display results in the same form tonedeaf1969 Programming 4 06-22-2007 07:55 AM
PHP: html Form Select function problem camlinux Programming 2 05-15-2005 08:23 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:42 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration