Forum Moderators: coopster

Message Too Old, No Replies

how to make a 'select' tag post by email

form, php, select, email

         

PublicSphere

2:36 pm on Jan 23, 2007 (gmt 0)

10+ Year Member



Hi everyone,

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.

jatar_k

3:15 pm on Jan 23, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



as an aside $HTTP_POST_VARS is no longer in use so use $_POST instead

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']

PublicSphere

4:26 pm on Jan 23, 2007 (gmt 0)

10+ Year Member



ah, thank you.

I had a feeling it might be something like that.

I'll have a play around and try to get it to work and I'll change the old language to the new language.

Thanks again.

PublicSphere

6:08 pm on Jan 23, 2007 (gmt 0)

10+ Year Member



ok, so now I've got:

$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?

jatar_k

7:29 pm on Jan 23, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



are these posted from somewhere

$_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

PublicSphere

8:17 pm on Jan 23, 2007 (gmt 0)

10+ Year Member



ah yes that works now. thank you very much.

jatar_k

8:18 pm on Jan 23, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



always a pleasure