I have a form that I have been working on and I've been having problems only with the radio buttons not showing up on the emails I receive. I have tried everything to get the right code but I am not sure what to do...PLEASE HELP!
here is my code for the visual .php:
<p style="color: #e40001;">* Denotes required field.</p>
<p><strong>General Information:</strong></p>
<form method="post" name="commentForm" action="sendmail.php">
<p>Your Name: <font size="2" color="#e40001">*</font>
<input type="text" name="name" value="" size="20" class="required" />
</p>
<br />
<p>Your Title:
<input type="text" name="title" value="" size="20" />
</p>
<p>Company: <font size="2" color="#e40001">*</font>
<input type="text" name="company" value="" size="20" class="required" />
</p>
<p>Email: <font size="2" color="#e40001">*</font>
<input type="text" name="email" value="" size="20" class="required" />
</p>
<p>Website:
<input type="text" name="website" value="" size="20" />
</p>
<p>Address:
<input type="text" name="address" value="" size="20" />
</p>
<p>City:
<input type="text" name="city" value="" size="20" />
</p>
<p>State/Provice: <font size="2" color="#e40001">*</font>
<input type="text" name="State" value="" size="20" class="required" />
</p>
<p>Zip Code: <font size="2" color="#e40001">*</font>
<input type="text" name="zip" value="" size="20" class="required" />
</p>
<p>Phone: <font size="2" color="#e40001">*</font>
<input type="text" name="phone" value="" size="20" class="required" />
</p>
<p>Fax:
<input type="text" name="fax" value="" size="20" />
</p><br /><br />
<p><strong>Professional Information:</strong></p>
<p>Type of business?
<SELECT name="operation"><option>--Select Operation--
<option>---------------------
<OPTION value=cafe/bar>Café/coffee bar
<OPTION value=restaurant>Restaurant/Bar
<OPTION value=kiosk>Kiosk
<OPTION value=hotel>Hotel/Motel
<OPTION value=university>University
<OPTION value=hospital>Hospital
<OPTION value=grocer/market>Grocer/Market
<OPTION value=other>Other
</select></p>
<p>If other, please desribe:
<input type="text" name="other" value="" size="20" />
</p><br /><br />
<p>Is this a new business?
<input type="radio" name="newsletter-yes" id="radio" value="No" title开发者_StackOverflow社区="Check No if you would not like our newsletter" />New
<input type="radio" name="newsletter-no" id="radio2" value="Yes" title="Check Yes if you would like our newsletter" />Existing</p>
<p>I am interested in learning more about the following equipment:<br />
<input type="radio" name="equipment" id="radio" value="BUNN Commercial Brewing & Gridning Equipment">BUNN Commercial Brewing & Gridning Equipment <br />
<input type="radio" name="equipment" id="radio" value="La Marzocco Traditional Espresso Machines">La Marzocco Traditional Espresso Machines<br />
<input type="radio" name="equipment" id="radio" value="Rancilio Traditional Espresso Machines">Rancilio Traditional Espresso Machines <br />
<input type="radio" name="equipment" id="radio" value="Egro Superautomatic Espresso Machines">Egro Superautomatic Espresso Machines <br />
<input type="radio" name="equipment" id="radio" value="Mazzer/Swift Espresso Grinders/Dosers">Mazzer/Swift Espresso Grinders/Dosers<br />
<input type="radio" name="equipment" id="radio" value="Blendtec Blenders">Blendtec Blenders <br />
</p>
<p>I am interested in learning more about the following products:<br />
<input type="radio" name="products" id="radio1" value="" title="" />Espressions Coffees/Teas<br />
<input type="radio" name="products" id="radio1" value="" title="" />Monin All-Natural Syrups, Sauces & Frappes <br />
<input type="radio" name="products" id="radio1" value="" title="" />Big Train Frozen Drink Bases<br />
<input type="radio" name="products" id="radio1" value="" title="" />Pacific Natural Foods Soy/Vanilla Soy, Smoothie Bases, Almond Milk<br />
<input type="radio" name="products" id="radio1" value="" title="" />Two Leaves and a Bud Tea Sachets<br />
<input type="radio" name="products" id="radio1" value="" title="" />Umpqua Oats<br />
</p>
<p>I am interested in learning more about your barista training program:
<input type="radio" name="barista training no" id="radio" value="No" title="Check No if you are not interested" />No
<input type="radio" name="barista training yes" id="radio2" value="Yes" title="Check Yes if you are interested" />Yes</p>
<p>Questions/ Comments:
<input type="text" name="other2" value="" size="40" />
</p>
<p><input type="submit" value="Send" />
<input type="reset" value="Reset" /></p>
</form><br /><br />
Here is my code for sendmail.php:
// values from POST data
$name = $_POST['name'];
$title = $_POST['title'];
$company = $_POST['company'];
$email = $_POST['email'];
$website = $_POST['website'];
$address = $_POST['address'];
$city = $_POST['city'];
$State = $_POST['State'];
$zip = $_POST['zip'];
$equipment = $_POST['equipment'];
$products = $_POST['products'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$operation = $_POST['operation'];
$other = $_POST['other'];
$newsletter = $_POST['newsletter'];
$click1 = $_POST['click1'];
$click2 = $_POST['click2'];
$click3 = $_POST['click3'];
$click4 = $_POST['click4'];
$click5 = $_POST['click5'];
$click6 = $_POST['click6'];
$push1 = $_POST['push1'];
$push2 = $_POST['push2'];
$push3 = $_POST['push3'];
$push4 = $_POST['push4'];
$push5 = $_POST['push5'];
$push6 = $_POST['push6'];
// subject
$subject = 'Espressions Coffee Roastery Contact Form';
// message
$message = '
<html>
<head>
<title>Espressions Coffee Roastery Contact Form</title>
</head>
<body>
<p>Name: '.$name.'</p>
<p>Title: '.$title.'</p>
<p>Company: '.$company.'</p>
<p>Email: '.$email.'</p>
<p>Website: '.$website.'</p>
<p>Address: '.$address.'</p>
<p>city: '.$city.'</p>
<p>State: '.$State.'</p>
<p>Zip Code: '.$zip.'</p>
<p>Phone: '.$phone.'</p>
<p>Fax: '.$fax.'</p>
<p>Operation: '.$operation.'</p>
<p>Other: '.$other.'</p>
<p>Newsletter: '.$newsletter.'</p>
<p>questions: '.$other2.'</p>
<p>BUNN Commercial: '.$click1.'</p>
<p>La Marzocco: '.$click1.'</p>
<p>Ranchilio Traditional: '.$click1.'</p>
<p>Egro Superautomatic: '.$click1.'</p>
<p>Mazzer/ Swift Espresso: '.$click1.'</p>
<p>Blendtec Blenders: '.$click1.'</p>
<p>Espressions: '.$push1.'</p>
<p>Monin All-Natural: '.$push1.'</p>
<p>Big Train Frozen Drink: '.$push1.'</p>
<p>Pacific Natural Foods: '.$push1.'</p>
<p>Two Leaves and a Bud: '.$push1.'</p>
<p>interested in products: '.$radio.'</p>
<p>interested in services: '.$radio1.'</p>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Espressions Coffee Roastery <max@estudioray.com>' . "\r\n";
$headers .= 'From: Espressions Coffee Roastery Contact Form <max@estudioray.com>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
Think the problem is here:
<p>interested in products: '.$radio.'</p>
<p>interested in services: '.$radio1.'</p>
It should be:
<p>interested in products: '.$products.'</p>
<p>interested in services: '.$equipment.'</p>
You've used the id
attribute of the radio element and not the name
attribute in your email code when you should just use what you have set it to at the top of your sendmail.php script which is $products
and $equipment
.
精彩评论