Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How to send checkbox selections in a form to email

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #40341
    monc
    Member

    Hi, I am having issues capturing data from the checkboxes in my form. I can’t figure out what code needs to go into the php file for multiple selections.

    The rest of the form is fine so I have left out most of the coding. Below is my html code for the checkboxes and my full php code as it stands.

    Any guidance/code would be greatly aprpeciated. Thanks in advance!

    **HTML Code**

    Please select your preferred sessions:

    Morning: 10am – 1pm

    Afternoon: 2pm – 5pm

    Evening: 7pm – 10pm

    **PHP Code**
    $EmailTo = “[email protected]”;
    $Subject = “Registration;
    $Fullname = Trim(stripslashes($_POST));
    $Email = Trim(stripslashes($_POST));
    $Session = Trim(stripslashes($_POST));

    // validation
    $validationOK=true;
    if (!$validationOK) {
    print ““;
    exit;
    }

    // prepare email body text
    $Body = “”;
    $Body .= “Fullname: “;
    $Body .= $Fullname;
    $Body .= “n”;
    $Body .= “Email: “;
    $Body .= $Email;
    $Body .= “n”;
    $Body .= “Session: “;
    $Body .= $Session;
    $Body .= “n”;

    // send email
    $success = mail($EmailTo, $Subject, $Body, “From: <$EmailFrom>“);

    // redirect to success page
    if ($success){
    print ““;
    }
    else{
    print ““;
    }
    ?>

    #112096
    Malazath
    Member

    Try putting the code in the given “Code” tag when posting. That post is a jumbled mess and I don’t even want to attempt to decipher it! :P

    #112101
    Paulie_D
    Member

    Fixed some of it.

    #112128
    irish1381
    Member

    Checkbox’s return yes or no as a value. You would have to have 3 unique names for each checkbox and use PHP to see which returned YES or NO.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.