Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need some quick help with a very simple formmail.php ASAP!

    So here is the deal, I have never coded in PHP but I understand the concept of programming. Nevertheless, we have a very basic formmail.php template that we use at my job, however it does not contain a method for being able to send multiple checkboxes within the same group. Can someone please help me out with this. I put a sample of the html code below along with the whole .php file.

    HTML

    <input type="checkbox" name="painpoints" value="value1" />
    <input type="checkbox" name="painpoints" value="value2" />
    <input type="checkbox" name="painpoints" value="value3" />
    <input type="checkbox" name="painpoints" value="value4" />

    Our formmail.php file code:

    <?php
    $to = "someone@somewhere.com";
    $from = "Asdf Inc.";
    $subject = "New Information Submitted";
    $body = "Below is the result of your feedback form. It was submitted by ";
    $body .= $_POST[name] . " (" . $_POST["email"] . ") on " . date("l, F j, Y - g:i:s A") . "\n\n";
    /*
    foreach($_POST as $key => $value) {
    if ($value == "Interested") {
    $body .= $key . ": " . $value . "\n";
    }
    }
    */
    $body .= "First Name: " . $_POST[firstname] . "\n";
    $body .= "Last Name: " . $_POST[lastname] . "\n";
    $body .= "Company: " . $_POST[company] . "\n";
    $body .= "Address 1: " . $_POST[address1] . "\n";
    $body .= "Address 2: " . $_POST[address2] . "\n";
    $body .= "City/Town: " . $_POST[city] . "\n";
    $body .= "State/Province: " . $_POST[state] . "\n";
    $body .= "ZIP: " . $_POST[zip] . "\n";
    $body .= "Email: " . $_POST[email] . "\n";
    $body .= "Phone: " . $_POST[phone] . "\n";
    $body .= "Comments: " . $_POST[comments] . "\n";
    $body .= "Pain Points/Areas of Interest: " .$POST[painpoints] THIS DOES NOT WORK !
    mail($to, $subject, $body, "From: " . $from . "\nReceived-From: " . $from);
    header("Location: index.html");
    ?>

    Edit/Delete Message

  • #2
    New Coder
    Join Date
    Dec 2007
    Location
    UK
    Posts
    41
    Thanks
    1
    Thanked 7 Times in 7 Posts
    I think you would need a foreach loop to build the $body string to include each entry in the array $POST[painpots]

    http://www.w3schools.com/php/func_array_each.asp

  • #3
    New Coder
    Join Date
    Dec 2007
    Posts
    96
    Thanks
    8
    Thanked 1 Time in 1 Post
    Make sure that the line ends with ";" . did it work?
    Last edited by skmd; 01-05-2008 at 02:27 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •