I just finished creating my form and .php file to mail it to an email address. All the input fields are working properly, except one. I can not get a drop down (Main Category) submission field to email me the submission. The form works fine on the website, the email leaves that one field blank. Any help in my coding would be greatly appreciated.
form:
<form action="merchantsignup.php" method="post" id="contact_form">
<center><table width="637" border="0">
<tr>
<td>Business Name:
<br />
<input type="text" name="name" /></td>
<td>Business Phone:
<br />
<input type="text" name="phone" /></td>
<td>Business Email:
<br />
<input type="text" name="email" /></td>
</tr>
<tr>
<td>Business Address:
<br />
<input type="text" name="address" /></td>
<td>City & Zip:
<br />
<input type="text" name="city/zip" /></td>
<td>Business Webpage:
<br />
<input type="text" name="webpage" /></td>
</tr>
<tr>
<td>Main Category<br />
<select name="Main Category">
<option value="Food">Food</option>
<option value="Soda">Soda</option>
<option value="Candy">Candy</option>
</select>
</td>
<td>Sub Category:
<br />
<input type="text" name="category2" /></td>
<td><p> </p></td>
</tr>
<tr>
</table>
<td><p>About the Business: <br />
<textarea cols="88" rows="8" name="about"></textarea>
</h3>
</p>
<p><input type="submit" name="submit" value="Send" />
<input type="reset" name="reset" value="Clear Form" /></p>
</form>
.php file
<?php
/* Email Variables */
$emailSubject = 'Merchant Signup';
$webMaster = 'info@lf.com';
/* Data Variables */
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city/zip'];
$webpage = $_POST['webpage'];
$main_category = $_POST['main'];
$category2 = $_POST['category2'];
$about = $_POST['about'];
$copy_photo[0]="";
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Phone: $phone <br>
Email: $email <br>
Address: $address <br>
City: $city <br>
Wegpage: $webpage <br>
Main Category: $Main <br>
Category2: $category2 <br>
About: $about <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=http://lf.com/index.shtml">
<style type="text/css">
<!--
body {
background-color: #000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #FF0000;
text-decoration: none;
padding-top: 400px;
margin-left: 250px;
width: 800px;
}
-->
</style>
</head>
<div align="center"> Thank you for submitting your information! You will recieve an email from us shortly! </div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
Any help would be greatly greatly appreciated!
Your form doesn't match your script. Try to be consistent in your naming conventions. Also, PHP is cAsE sEnSiTiVe so you need to pay attention to that as well.
Change this in your form:
<select name="Main Category">
to this:
<select name="main_category">
And change this data variable in PHP:
$main_category = $_POST['main'];
to this:
$main_category = $_POST['main_category'];
It should work now.
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
00rDog -
What exactly do you mean that there is no validation or sanitation for the form fields? Also, could you point me in a general direction on how to tighten up the security? Google search's aren't quite specific enough as I'm not quite sure what needs to be done.
Are you refering to a captcha, or hidden fields to avoid spam messages perhaps?
Thanks!
jrandazzo, I came on here looking for a script for my email form and I was wondering if I could use the one you posted above? I'm assuming its working with the doctype xhtml/1.0 transitional?
The one I have every element is getting flagged as not valid with xhtml when I use the nifty code validator W3C Nancy posted.
Nancy, in case you happen to see this and might can help me (again) my page is here: http://www.healthquestpt.com/hpc/contact.html
I like this PHP script. It has form validation, security and spam protection built-in.
http://www.dbmasters.net/node/19
This discussion details how to get it working with your HTML form:
http://forums.adobe.com/thread/912801
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
North America
Europe, Middle East and Africa
Asia Pacific