No... honestly... I mean this is REALLY dumb!

I have a form with a select that looks like this:

<select name='toasters'>
<option value='1'>Toaster 1</option>
<option value='2'>Toaster 2</option>
<option value='3'>Toaster 3</option>
<option value='4'>Toaster 4</option>
</select>

In my php I read (or try to read) the value with:

$toaster = $_POST['toasters'];

No matter which toaster is selected, $toaster returns '0' as in $toaster = 0; when it absolutely should be returning 1-4.

At first I thought this might be happening because the select was not being changed so it was somehow defaulting to ZERO but on further testing and changing the select to which ever toaster I want $_POST still returns a big fat ZERO.

(and no, this is NOT a multi-select)

All other fields and values are being returned correctly... just not the select! The select is displaying properly on the page, it functions properly, I can view source and it has the values/options it is supposed to have etc.

What in the world am I doing wrong here?

Thanks,

Pete

Recommended Answers

All 4 Replies

Is your select inside the <form> tag, and do a var_dump($_POST); to see the values of everything passed from the form

can u provide the code? so that we can trace it.... bec. u fail to show it to us... i suspect that 2 possible reason. 1) maybe you put that code outside your html form. 2.) maybe the form method you use is 'get' and not 'post'. coz. your retrieving your values using the $_POST[] global variable.

Is your select inside the <form> tag, and do a var_dump($_POST); to see the values of everything passed from the form

I told you it was really dumb!!!

To avoid further embarassement we'll not mention that the select was two lines above the form tag and we'll appreciate it if no one else mentioned it either! :twisted:

then mark this thread solved then...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.