Forum Moderators: coopster
I'm very new to PHP, it's not something I intend to specialise in either. But I use php for my contact forms.
In the past i've always used 'input' and 'textarea' form objects and my contact forms have worked fine.
Now though, I want to use a select, like this:
<select name="logo-design">
<option value="<?php echo($HTTP_POST_VARS['no-i-have-one-for-you-to-use'])?>">No
- I have one for you to use</option>
<option value="<?php echo($HTTP_POST_VARS['no-I-dont-need-one'])?>">No
- I don't need one</option>
<option value="<?php echo($HTTP_POST_VARS['yes-use-my-existing-logo'])?>">Yes
- use my existing logo</option>
</select>
and in the head of my page I have:
$lgdsgn1 = $HTTP_POST_VARS['no-I-have-one-for-you-to-use'];
$lgdsgn2 = $HTTP_POST_VARS['no-I-dont-need-one'];
$lgdsgn3 = $HTTP_POST_VARS['yes-use-my-existing-logo'];
...and...
$msgText = "
Name: $name
Do you want want logo design?: $lgdsgn1 / $lgdsgn2 / $lgdsgn3
...etc...
But this doesn't work. I just get...
Do you want want logo design?: / /
...in my emails.
Does anyone know how to properly use a select tag in a PHP form like this?
I really appreciate the help.
you have the wrong var name
a select will only send the single selected option
the name of the variable found in your POST will be found here
<select name="logo-design">
the selected option will be found in this var
$_POST['logo-design']
$lgdsgn = $_POST['logo-design'];
...and...
Do you want want logo design?: $lgdsgn
...in the head, and...
<select name="logo-design">
<option value="<?php echo($_POST['no-i-have-one-for-you-to-use'])?>">No
- I have one for you to use</option>
<option value="<?php echo($_POST['no-I-dont-need-one'])?>">No
- I don't need one</option>
<option value="<?php echo($_POST['yes-i-need-a-new-logo'])?>">Yes
- I need a new logo</option>
</select>
...in the body.
Still, though, I get nothing in my email.
I must admit I am guessing, but I thought this might work. Do you know what I'm doing wrong?
$_POST['no-i-have-one-for-you-to-use']
$_POST['no-I-dont-need-one']
$_POST['yes-i-need-a-new-logo']
otherwise you may want to just have the strings in there like so
<select name="logo-design">
<option value="no-i-have-one-for-you-to-use">No
- I have one for you to use</option>
<option value="no-I-dont-need-one">No
- I don't need one</option>
<option value="yes-i-need-a-new-logo">Yes
- I need a new logo</option>
</select>
then the selected string should show up in the email