Grow your CSS skills. Land your dream job.

Need help in getting checkbox results into email body

  • # March 15, 2013 at 11:30 am

    I have a “Get a Quote” form on my website that has multiple checkboxes. I would like a list of the choices to appear in the email that I ultimately receive. Having tried a number of different code solutions I’m still not seeing the checkbox results in the sent emails. I’m sending the code and the html in hopes that forum users will be able to suggest where I’m going wrong. (I will admit that I’m a newbie – so please be gentle – I’m sending all of the code just in case)

    **Here’s the pertinent html **

    < ?php session_start(); ?>
    < !DOCTYPE html>
    ****

    method=”post” action=”process_quote.php”>












    < ?php unset($_SESSION); ?>

    **Here’s the applicable php:**

    < ?php
    if( isset($_POST) ){

    //form validation vars

    $formok = true;
    $errors = array();

    //submission data

    $ipaddress = $_SERVER;
    $date = date(‘m/d/Y’);
    $time = date(‘H:i:s’);

    //form data

    $name = $_POST;
    $email = $_POST;
    $telephone = $_POST;
    $company = $_POST;
    $web = $_POST;
    $budget = $_POST;

    if (isset ($_POST )){
    $WebD = $_POST ;
    }
    else {
    $WebD = “”;
    }

    if (isset ($_POST )) {
    $LogoD = $_POST ;
    }
    else {
    $LogoD = “”;
    }

    if (isset ($_POST )){
    $BCard = $_POST ;
    }
    else {
    $BCard = “”;
    }

    if (isset ($_POST )) {
    $Stationery = $_POST ;
    }
    else {
    $Stationery = “”;
    }

    if (isset ($_POST )){
    $Brochure = $_POST ;
    }
    else {
    $Brochure = “”;
    }

    if (isset ($_POST )) {
    $Pcard = $_POST ;
    }
    else {
    $Pcard = “”;
    }

    if (isset ($_POST )){
    $RCard = $_POST ;
    }
    else {
    $RCard = “”;
    }

    if (isset ($_POST )) {
    $Flyers = $_POST ;
    }
    else {
    $Flyers = “”;
    }

    if (isset ($_POST )){
    $Newsletter = $_POST ;
    }
    else {
    $Newsletter = “”;
    }

    if (isset ($_POST )) {
    $Ads = $_POST ;
    }
    else {
    $Ads = “”;
    }

    if (isset ($_POST )) {
    $Other = $_POST ;
    }
    else {
    $Other = “”;
    }

    //validate form data

    //validate name is not empty

    if(empty($name)){
    $formok = false;
    $errors[] = “We need your name”;
    }

    //validate email address is not empty

    if(empty($email)){
    $formok = false;
    $errors[] = “Please enter an email address”;

    //validate email address is valid

    }elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
    $formok = false;
    $errors[] = “You have not entered a valid email address”;
    }

    //send email if all is ok

    if($formok){
    $headers = “From: quote@modsnapdesign.com” . “rn”;
    $headers .= ‘Content-type: text/html; charset=iso-8859-1′ . “rn”;

    $emailbody = “

    You have recieved a quote request.

    Name: {$name}

    Email Address: {$email}

    Telephone: {$telephone}

    Company Name: {$company}

    Website: {$web}

    Budget: {$budget}

    //this is where my checkbox results should be in the email body how do I code for them here?

    Message: {$message}

    This message was sent from the IP Address: {$ipaddress} on {$date} at {$time}

    “;

    mail(“modsnap@gmail.com”,”Gimme a quote, Modsnap”,$emailbody,$headers);

    }

    //what we need to return back to our form
    $returndata = array(
    ‘posted_form_data’ => array(
    ‘name’ => $name,
    ‘email’ => $email,
    ‘telephone’ => $telephone,
    ‘company’=> $company,
    ‘web’=> $web,
    ‘budget’=> $budget,
    ‘services’=> $services,
    ‘message’ => $message
    ),
    ‘form_ok’ => $formok,
    ‘errors’ => $errors
    );

    //if this is not an ajax request
    if(empty($_SERVER) && strtolower($_SERVER) !== ‘xmlhttprequest’){
    //set session variables
    session_start();
    $_SESSION = $returndata;

    //redirect back to form
    header(‘location: ‘ . $_SERVER);
    }
    }

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".