Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

captainmeowtron

macrumors member
Original poster
Dec 1, 2008
43
0
I'm having a problem with this formmail. I can't figure out how to do the foreach statement correctly. It should send the information from the checkboxes.
php:
Code:
<?php
$name = $_REQUEST['name'] ;
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;
  foreach($_POST['services'] as $value) {
$check_msg .= "Checked: $value\n";
}

  mail( "services@captainmeowbot.com", "Quote Request",
    $message, "From: $email" );
  header( "Location: http://www.captainmeowbot.com/thanks.html" );
?>
and the accompanying html code:
Code:
<html>
<head>
<title>select</title>
<style type="text/css">
  <!--
       A:link {text-decoration: none;}
       A:visited {text-decoration: none;}
  -->
</style>
</head>
<body>
<body bgcolor="#FFFFFF" >		
<img src="quote.jpg" width="800" height="50" alt="" border="0" align="">
<blockquote>
<table>

<form action="formmail.php" method="post" name="simpleform" id="simpleform">
  
Name: <input name="name" type="text" /><br />
Email: <input name="email" type="text" /><br />

<p>Which services are you interested in?</p>
<input type="checkbox" name="services" value="printing services and graphic design">printing services and graphic design</p>
<p>     <input type="checkbox" name="services" value="business cards">business cards
     <input type="checkbox" name="services" value="letterhead">letterhead
     <input type="checkbox" name="services" value="postcards">postcards</p>
<p>
<input type="checkbox" name="services" value="image, video, and sound preparation">image, video, and sound preparation<br></p>
<p>     <input type="checkbox" name="services" value="scanning and image adjustment">scanning and image adjustment
     <input type="checkbox" name="services" value="quicktime files and sound editing">quicktime files and sound editing
   <input type="checkbox" name="services" value="mp3s and sound editing">mp3s and sound editing</p>

<p>Description:<br />
  <textarea name="message" rows="7" cols="60">
  </textarea><br /></p><p>
  <input type="submit" value="Submit Form" alt="submit form"></p>
</form>
</table>
</body>
</html>
 

Darth.Titan

macrumors 68030
Oct 31, 2007
2,905
753
Austin, TX
The services checkboxes each need to have the name of "services[]" so the values will be put into an array that foreach can parse.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.