468,536 Members | 1,515 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,536 developers. It's quick & easy.

How to get value from drop down box to e-mail with php

I have a form that includes a drop down box. I can get all of the other
values to show up in an e-mail except for the drop down box values. Can
someone please help? -- I know the HTML isn't the greatest. The website
was originally created in FrontPage and the form broke. I'm just trying
to help out and fix it for a friend.

sendmail.php
<?
$Name = $_REQUEST['name'] ;
$Comments = $_REQUEST['comments'] ;
$Email = $_REQUEST['email'] ;
$Telephone = $_REQUEST['telephone'];
$Fax = $_REQUEST['fax'];
$Subject = $_REQUEST['subject'];
$SubjectOther = $_REQUEST['subjectother'];
$ContactRequested = $_REQUEST['contactrequested'];

mail( "ka********@site-seeker.com", "RCI Waterjets Contact Us Form",
"Name: $Name \n\nComments: $Comments \n\nEmail: $Email
\n\nTelephone: $Telephone \n\nFax: $Fax \n\nSubject: $Subject
\n\nSubject Other: $SubjectOther \n\nContact Requested:
$ContactRequested", "From: ka********@site-seeker.com" );
header( "Location: http://www.rciwaterjets.com/Thanks.htm" );
?>

ContactUsNEW.htm
<form method="post" action="sendmail.php">
<p align="center">
&nbsp;<textarea name="comments" rows="8" cols="66">Please Enter your
details here</textarea></p>
<dl>
<dd>
<table width="450">
<tr>
<td width="84" align="right"><font size="2">Name</font></td>
<td width="286" align="center">
<p align="center">
&nbsp;<input name="name" type="text" size="35" maxlength="256"/></td>
<td width="66">Required</td>
</tr>
<tr>
<td width="84" align="right"><font size="2">E-mail</font></td>
<td width="286" align="center">
<p align="center">
<input name="email" type="text" size="35" maxlength="256"/></td>
<td width="66">Optional</td>
</tr>
<tr>
<td width="84" align="right"><font size="2">Tel</font></td>
<td width="286" align="center">
<p align="center">
&nbsp;<input name="telephone" type="text" size="35"
maxlength="256"/></td>
<td width="66">Optional</td>
</tr>
<tr>
<td width="84" align="right"><font size="2">Fax</font></td>
<td width="286" align="center">
<p align="center">
<input name="fax" type="text" size="35" maxlength="256"/></td>
<td width="66">Optional</td>
</tr>
</table>
</dd>
</dl>
<dl>
<dd>
<table width="448">
<tr>
<td width="88" align="right"><select name="Subject" size="1">
<option selected>Web Site</option>
<option>Company</option>
<option>Products</option>
<option>Store</option>
<option>Employee</option>
<option>(Other)</option>
</select> </td>
<td width="38">
<p align="center"><font size="2">Other:</font></td>
<td width="252">
<input name="subjectother" type="text" size="35"
maxlength="256"/></td>
<td width="52">&nbsp;</td>
</tr>
<tr>
<td width="88" align="right">&nbsp;</td>
<td width="351" colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="88" align="right"><input name="contactrequested"
type="checkbox"></td>
<td width="351" colspan="3">
<p align="center">Please contact me as soon as possible regarding
this matter.</td>
</tr>
<tr>
<td width="442" align="right" colspan="4">
<p align="center"><input type="submit"/><input type="reset"
value="Reset" name="B2"></td>
</tr>
</table>
</dd>
</dl>
<p
align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;
</p>
</form>

Jun 30 '06 #1
7 2191
Syl

kandi111777 wrote:
I have a form that includes a drop down box. I can get all of the other
values to show up in an e-mail except for the drop down box values. Can
someone please help? -- I know the HTML isn't the greatest. The website
was originally created in FrontPage and the form broke. I'm just trying
to help out and fix it for a friend.

sendmail.php
$Subject = $_REQUEST['subject'];
<td width="88" align="right"><select name="Subject" size="1">
<option selected>Web Site</option>
<option>Company</option>
<option>Products</option>
<option>Store</option>
<option>Employee</option>
<option>(Other)</option>
</select> </td>

You're missing a value in the option of the drop down

Change all the options like this --> <option>Company</option>
to this --> <option value="company">Company</option>
to this --> <option value="employee">Employee</option>

etc, etc,

Jun 30 '06 #2
I made the changes so now it looks like this:

<td width="88" align="right"><select name="Subject" size="1">
<option selected value="website">Web Site</option>
<option value="company">Company</option>
<option value="products">Products</option>
<option value="store">Store</option>
<option value="employee">Employee</option>
<option value="other">Other</option>
</select> </td>

But it still isn't working. My e-mail looks like this:

Name: Kandi M. Humpf
Comments: test
Email: ka***@kandiandkeith.com
Telephone: 315-292-6819
Fax: 3157353994
Subject:
Subject Other:
Contact Requested: on

Do you have another suggestion?

Syl wrote:
You're missing a value in the option of the drop down

Change all the options like this --> <option>Company</option>
to this --> <option value="company">Company</option>
to this --> <option value="employee">Employee</option>

etc, etc,


Jun 30 '06 #3
Thanks! It works now...I had to change:

<select name="selectitem" size="1">

and

$Subject = $_POST['selectitem'];

Okay, now do you happen to know how to BCC a recipient?

Jun 30 '06 #4
"Syl" <da**********@gmail.com> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...

kandi111777 wrote:
I have a form that includes a drop down box. I can get all of the other
values to show up in an e-mail except for the drop down box values. Can
someone please help? -- I know the HTML isn't the greatest. The website
was originally created in FrontPage and the form broke. I'm just trying
to help out and fix it for a friend.

sendmail.php
$Subject = $_REQUEST['subject'];
<td width="88" align="right"><select name="Subject" size="1">
<option selected>Web Site</option>
<option>Company</option>
<option>Products</option>
<option>Store</option>
<option>Employee</option>
<option>(Other)</option>
</select> </td>

You're missing a value in the option of the drop down

Change all the options like this --> <option>Company</option>
to this --> <option value="company">Company</option>
to this --> <option value="employee">Employee</option>

That's not an issue, if value is not given, then anything that's inside the
<option></option> will be used instead. In this case for example
<option>Company</option> Company will be used since it lacks value.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Jun 30 '06 #5
Message-ID: <11**********************@h44g2000cwa.googlegroups .com> from
kandi111777 contained the following:
<select name="selectitem" size="1">

and

$Subject = $_POST['selectitem'];
All you really had to do was make sure they were the same case. You had
$Subject = $_REQUEST['subject'];
and
<select name="Subject" size="1">
Okay, now do you happen to know how to BCC a recipient?


mail( "ka********@site-seeker.com", "RCI Waterjets Contact Us Form",
"Name: $Name \n\nComments: $Comments \n\nEmail: $Email
\n\nTelephone: $Telephone \n\nFax: $Fax \n\nSubject: $Subject
\n\nSubject Other: $SubjectOther \n\nContact Requested:
$ContactRequested", "From: ka********@site-seeker.com
\nBcc:me@example.com" );

Doesn't work on some setups though. Check with your service provider.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jun 30 '06 #6
Kimmo Laine wrote:
"Syl" <da**********@gmail.comwrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
>kandi111777 wrote:
>>I have a form that includes a drop down box. I can get all of the other
values to show up in an e-mail except for the drop down box values. Can
someone please help? -- I know the HTML isn't the greatest. The website
was originally created in FrontPage and the form broke. I'm just trying
to help out and fix it for a friend.

sendmail.php
$Subject = $_REQUEST['subject'];
<td width="88" align="right"><select name="Subject" size="1">
<option selected>Web Site</option>
<option>Company</option>
<option>Products</option>
<option>Store</option>
<option>Employee</option>
<option>(Other)</option>
</select</td>

You're missing a value in the option of the drop down

Change all the options like this --<option>Company</option>
to this --<option value="company">Company</option>
to this --<option value="employee">Employee</option>


That's not an issue, if value is not given, then anything that's inside the
<option></optionwill be used instead. In this case for example
<option>Company</optionCompany will be used since it lacks value.
Browser dependent, MS IE doesn't set the value by default. It really
becomes noticeable in JavaScript if you test for someSelectElement.value
will fail in IE if you do not explicitly set the value attributes on the
OPTION elements...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jul 3 '06 #7
Jonathan N. Little:
Kimmo Laine wrote:
That's not an issue, if value is not given, then anything that's inside the
<option></optionwill be used instead. In this case for example
<option>Company</optionCompany will be used since it lacks value.

Browser dependent, MS IE doesn't set the value by default. It really
becomes noticeable in JavaScript if you test for someSelectElement.value
will fail in IE if you do not explicitly set the value attributes on the
OPTION elements...
not disputing that, but I'd point out that the spec is quite clear
when it says, as Kimmo said, that in the absence of a value attribute,
the value is set to the element's content.

--
Jock

Jul 3 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Xerxes | last post: by
reply views Thread by LU | last post: by
1 post views Thread by Dan | last post: by
4 posts views Thread by Martyn Fewtrell | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.