This seems like a popular problem but I just couldn't figure it out from previous posts.

I have a form...

	
<form action="processa.php" method="post">

Your Name:<input name="name" type="text">
Email:<input name="email" type="text">

<br>

Choose your services:

<input name="services[A]" type="checkbox"> A
<input name="services[B]" type="checkbox"> B
<input name="services[C]" type="checkbox"> C
<input name="services[D]" type="checkbox"> D
<input name="services[E]" type="checkbox"> E
<input name="services[F]" type="checkbox"> F

<p class="smalltextc">Project Decsription</p>
<p>Go crazy.</p>
<textarea name="description" cols="42" rows="12"></textarea>
<input type="SUBMIT" name="Submit">

</form>

With some PHP...

<?php 
$to = "desk@claytonbellmor.com"; 
$subject = "Project Quote";
$name = $_REQUEST['name'];
$email = $_REQUEST['email'] ; 
$message = $_REQUEST['description'] ; 
$headers = "From: $email";

[put magical php here] <-- Get checked boxes and include it in the email sent!!!! If only I knew how.

$sent = mail($to, $subject, $message, $headers) ; 
if($sent) 
{print "Good Job!"; }
else 
{print "Kill yourself!"); }
?>

How do I include the checked boxes (in array services) to be included in the sent email!? I have no idea.

Thanks for any help!

    When I have used CHECKBOX's in th past the name that I have given them are all the same i.e.

    Where you have

    <input name="services[A]" type="checkbox"> A
    <input name="services[b]" type="checkbox"> B
    <input name="services[C]" type="checkbox"> C
    <input name="services[D]" type="checkbox"> D
    <input name="services[E]" type="checkbox"> E
    <input name="services[F]" type="checkbox"> F

    I would put

    <input name="services[]" VALUE='A' type="checkbox"> A
    <input name="services[]" VALUE='B' type="checkbox"> B
    <input name="services[]" VALUE='C' type="checkbox"> C
    <input name="services[]" VALUE='D' type="checkbox"> D
    <input name="services[]" VALUE='E' type="checkbox"> E
    <input name="services[]" VALUE='F' type="checkbox"> F

    Then when processing the form in processa.php there will be an array within the POST array named services containing all selected items.

    You could access this by;

    foreach ( $_POST['services'] as $SelectedService )
    {
        $message .= "User has selected " . $SelectedService . "<BR>\r\n\";
    }

    You might then want to wrap this in another wrapper to make sure that the user has selected services from the previous form, so the above would become...

    // If someone has previously selected a service, lets do something with it
    if ( isset($_POST['services']) )
    {
        // For every service selected, deal with it one at a time and name it $SelectedService
        foreach ( $_POST['services'] as $SelectedService )
        {
            // Take the current selected service and add the value to the current message.
            $message .= "User has selected " . $SelectedService . "<BR>\r\n\";
        }
    }

    Hope this helps?

      I understand how you concatenated the selected services to the $message.

      I'm in the process of adding it to my existing html/php.

      Give me a few minutes to, um, try to understand it!

      EDIT

      So... where do I put it?

        You would need to put the PHP in the place where you have referenced in your original post i.e.

        [put magical php here] <-- Get checked boxes and include it in the email sent!!!! If only I knew how.

        Any probs let me know...

          I tried adding your code but noticed that when I pasted it in that the first print command was turned into a string constant.

          I tried anyway and ran the script but it came back with a parse error.

          Here's my code with yours, hopefully it's a simple error on my part.

          <?php 
          $to = "desk@claytonbellmor.com"; 
          $subject = "Project Quote";
          $name = $_REQUEST['name'];
          $email = $_REQUEST['email'];
          $message = $_REQUEST['description'];
          $headers = "From: $email";
          if ( isset($_POST['services']) ) 
          {  
          foreach ( $_POST['services'] as $SelectedService ) { $message .= "User has selected " . $SelectedService . "<BR>\r\n\"; } } $sent = mail($to, $subject, $message, $headers, $name); if($sent) {print ("<img src=\"imgs/thanks.png\" alt=\"Thank you\" class=\"imgb\"/><br /><div class=\"smalltextb\">Your email was sent successfully.</div><br> <div class=\"smalltextc\">If there is anything you wanted to add to the quote or had a comment, feel free to use the <a href=\"contact.html\" alt=\"Link to contact form\">contact form</a> to do so or email me at desk@claytonbellmor.com</div>"); } else {print ("<img src=\"imgs/oops.png\" alt=\"Thank you\" class=\"imgb\"/><br /><div class=\"smalltextb\">There was a problem sending your quote. <br> Please hit the back button on your browser to re-send the form. <br>If the problem persists, please email me at desk@claytonbellmor.com</div>"); } ?>

          This looks a bit different from my previous code, the previous one I had cleaned up to make it easier to read, but since I'm getting parsing errors I thought to upload the whole chibang.

            I deleted the /r/n/ section of your code, uploaded it and the script ran perfectly.

            And the selected services were included in the email.

            Thanks a bunch for your help!

              Sorry ... should have checked it again.

              If you look at the \r\n section there is one too many slashes. This last one stopped the closing " terminating your string.

              If you remove the last '\' it should of just worked

              $message .= "User has selected " . $SelectedService . "<BR>\r\n"; 

              Sorry again...:o

                Write a Reply...