HTML Check list with PHP -


i have following form action in php. have used check list project names. if select projects in list coming array, array instead of original value (i.e. tatvam, amairo, vedam).

i getting message this

this message getting if select 1 project

jquery(".form-js-contact").submit(function () {     var thisform = jquery(this);     jquery('.required-error',thisform).remove();     var aname   = jquery("#aname").val();     var amail   = jquery("#amail").val();     var aphone  = jquery("#aphone").val();     var acomments   = jquery("#acomments").val();     var color   = jquery("input[name='color[]']").serializearray();      var psubject    = jquery("#psubject").val();      var data = {'aname':aname,'amail':amail,'aphone':aphone,'acomments':acomments,'psubject':psubject,'color':color};     if (aname == "") {         jquery("#aname").after('<span class="form-description required-error">required field.</span>');     }else {         jquery("#aname").parent().find('.required-error').remove();     }     if (amail == "") {         jquery("#amail").after('<span class="form-description required-error">required field.</span>');     }else {         jquery("#amail").parent().find('.required-error').remove();     }     if (aphone == "") {         jquery("#aphone").after('<span class="form-description required-error">required field.</span>');     }else {         jquery("#aphone").parent().find('.required-error').remove();     }     if (acomments == "") {         jquery("#acomments").after('<span class="form-description required-error">required field.</span>');     }else {         jquery("#acomments").parent().find('.required-error').remove();     }        if (aname != "" && amail != "" && aphone != "" && acomments != "" ) {         jquery.post("contact_us_contact.php",data,function (result) {             if (result == "done") {                 thisform.prepend("<div class='alert-message success-contact'><p><strong>thank "+name+"!</strong> we'll in touch real .</p></div>");                 jquery("#aname").val("");                 jquery("#amail").val("");                 jquery("#aphone").val("");                 jquery("#acomments").val("");              }         });     }     return false; }); 

this html code

<form class="form-style form-js-contact" action="contact_us_contact.php" method="post">                          <input type="hidden" name="psubject" id="psubject" value="enquiry contact page"> <div class="col-md-6 col-lg-6" > <input class=required-item value="" name=aname id=aname aria-required=true placeholder="your name*"></div> <div class="col-md-6 col-lg-6" ><input type=email class=required-item id=amail name=amail value="" aria-required=true placeholder="your email*"></div> <div class="col-md-6 col-lg-12" ><input class=required-item aria-required=true id=aphone name=aphone value="" placeholder="your phone*"></div>  <div class="col-md-3" style="margin-bottom:10px; "><h4>projects interested</h4></div> <div class="col-md-2" ><input name="color[]" id="color" class="check" type="checkbox" value="amairo">amairo</div> <div class="col-md-2" ><input name="color[]" id="color" class="check" type="checkbox" value="tatvam">tatvam</div> <div class="col-md-2" ><input name="color[]" id="color" class="check" type="checkbox" value="vedam">vedam</div>  <div class="col-md-6 col-lg-12" >  <textarea name="acomments" id="acomments" class=required-item aria-required=true placeholder="type message*"></textarea></div>  <div class="col-md-6 col-lg-6" > <input style=font-size:16px name=submit type=submit value="send enquiry" class="submit_buttom buttoncolor" id="main_contact_form"></div> </form> 

this php

     <?php      function clean_text($text='') {      $text = trim($text);      $text = strip_tags($text);      $text = addslashes($text);      $text = htmlspecialchars($text);      return $text;      }    if (!$_post) {     die();   }else {   if (empty($_post["aname"]) && empty($_post["aphone"]) &&      empty($_post["amail"])&& empty($_post["acomments"]) ) {     echo "all_empty"; }else if (empty($_post["aname"])) {     echo "empty_name"; }else if (empty($_post["amail"])) {     echo "empty_mail"; }else if (empty($_post["aphone"])) {     echo "empty_phone"; }else if (empty($_post["acomments"])) {     echo "empty_comments"; }else {          $your_email = "mail@mydomain.com";           $aname   = clean_text($_post["aname"]);     $amail   = clean_text($_post["amail"]);     $aphone  = clean_text($_post["aphone"]);     $acomments   = clean_text($_post["acomments"]);     $wname = $_post['color'];     $psubject    = clean_text($_post["psubject"]);     $subject  = "$psubject";       $headers  = "from: leads@mydomain.in". "\r\n";     $headers .= 'content-type: text/html; charset=utf-8'. "\r\n";     $msg      = "new message \n\r <br>";     $msg     .= "name : \t $aname \r\n <br>";     $msg     .= "email : \t $amail \r\n<br>";            $msg    .= "phone : \t $aphone \r\n<br>";        $msg    .= "message : \t $acomments \r\n<br>";     if (isset($wname)) {     $msg    .= "project(s) interested: \r\n";     $msg    .= "<ul> \r\n";     foreach ($wname $color){     $msg    .="<li>" .$color. "</li>  \r\n";  }      $msg    .= "</ul>";       } // isset      echo "done";     $done = @mail($your_email, $subject, $msg, $headers);     } } 

?>

you taking value of color in jquery id jquery("#color").val(); , per html rule there 1 id same name 1 value. have replace like

> jquery  var color = jquery("input[name='color[]']").serializearray(); 

and values of color in php code $wname = $_post['color'];


Comments