problem with formmail

Discussion in 'Web Design and Development' started by captainmeowtron, Aug 18, 2009.

  1. captainmeowtron macrumors member

    Joined:
    Dec 1, 2008
    #1
    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>
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
  3. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #3
    The services checkboxes each need to have the name of "services[]" so the values will be put into an array that foreach can parse.
     

Share This Page