Forums

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

Home Forums CSS Checkboxes in Contact Form

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

    Hello!

    I’m using the contact form and I have everything working great… except for a group of check boxes.
    When the email is sent only the first checked box in the group displays.
    Basically my form is like:
    Who do you serve (check all that apply)?
    [] residential
    [] offices
    [] industrial
    [] other

    If I check the 2nd and 3rd boxes, the email only displays that I checked the 2nd box.
    Do I need to make a change to the contact form, the processor, or both?

    Thanks in advance!

    #67971
    cybershot
    Participant

    what contact form are you using? You need to display the code that you are using for the m form.

    #67529
    Nato595
    Member

    I started with the template of:
    https://css-tricks.com/nice-and-simple-contact-form/

    Following is the PHP file that builds the email that is send to me:

    
    
    $EmailFrom = "[email protected]";
    $EmailTo = "[email protected]";
    $Services = Trim(stripslashes($_POST));

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

    // prepare email body text
    $Body = "";
    $Body .= "Services: ";
    $Body .= $Services;
    $Body .= "n";
    $Body .= "n";


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

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

    Here is the contact form that is filled out by the user:











    Services Provided (select all that apply):

    Commercial

    Residential

    Roll-off

    Landfill

    Transfer Station

    Portolet

    MRF

    Sweeping

    Landfill



    #67587
    cybershot
    Participant

    The only thing that I can think is to add to the form. You would start by changing the names of each of the services to something different. Like so


    Residential

    Roll-off

    Landfill

    Transfer Station

    Portolet

    MRF

    Sweeping


    Landfill

    then in your code, you will have to add the variables like so


    $residential = $_POST;
    $rolloff = $_POST;

    and so on

    then you will have to add each variable to your form body. But you can test them to see if they are filled out first. A checkbox will return true if it is checked. so you can change the code to send the checkbox only if it is checked. Google the code for php check box to learn how to tell if it is checked. I am not positive how to do it. Oh, and one more thing. You should not have multiple id’s of services. in a page, id is good for one. So change the id’s to fit also like id=”rolloff’, id=”residential” and so on.

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