0

the page will stop when i try to "tick" multiple checkbox .

may be coding error I don't know

form.php

<tr>
    <td><input type="checkbox" name="color[]"  value="YK GI ZincCoat&trade;"> YK GI ZincCoat&trade;</td>
    <td><input type="checkbox" name="color[]"  value="YK ColourCoat&trade;"> YK ColourCoat&trade;</td>
  </tr>
  <tr>
    <td><input type="checkbox" name="color[]" value="YK WarnaCanggih&trade; ColourCoat "> YK WarnaCanggih&trade; ColourCoat </td>
    <td><input type="checkbox" name="color[]" value="YK Self Cleaning&trade; ColourCoat"> YK Self Cleaning&trade; ColourCoat </td>
  </tr>

process.php

<?php


    $first= $_GET["first"];
    $job= $_GET["job"];
    $nature= $_GET["nature"];
    $color[]= $_GET["color[]"];
    $name= $_GET["name"];
    $jobtitle= $_GET["jobtitle"];
    $Company= $_GET["Company"];
    $address1= $_GET["address1"];
    $Tel= $_GET["Tel"];
    $Fax= $_GET["Fax"];
    $Handphone= $_GET["Handphone"];
    $Email= $_GET["Email"];





    require_once('lib/class.phpmailer.php');

    $mail             = new PHPMailer(); // defaults to using php "mail()"


    $mail->AddReplyTo("[email protected]","rusly");

    $mail->SetFrom('[email protected]', 'rusly');

    $mail->AddReplyTo("[email protected]","rusly");

    $address = "[email protected]";
    $mail->AddAddress($address, "rusly");

    $mail->Subject    = "Starshine Group - Enquiry Form";

    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

    $mail->Body = "Contact Us<br><br> 
    $first<br>
    job : $job<br>
    nature : $nature<br><br>
    Product Interest : $color[]<br>
    First Name : $name<br>
    Job Title : $jobtitle<br>
    Address : $address1<br> 
    Company : $Company<br> 
    Phone Number : $Tel<br> 
    Handphone : $Handphone<br>
    Email : $Email<br> 
    Fax : $Fax<br> 

    Thank You!<br>


    ";


    if(!$mail->Send()) {
      echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
      echo "
    First Name : $name<br>
    Address : $address1<br> 
    Phone Number :  $Tel<br> 
    Email : $Email<br> 


    Thank You!<br><br>

      Message sent!<br>";
    }

    ?>
0

3 Answers 3

3

use $color= $_GET["color"]; instead of $color[]= $_GET["color[]"];

$color will be array of values.

and use

Product Interest : ".implode(',', $color)."<br>  // this will add in format of value1,value2,value3  you can change comma to any other char

instead of Product Interest : $color[]<br>

Sign up to request clarification or add additional context in comments.

Comments

0

Try this

<?php

$first= $_GET["first"]; $job= $_GET["job"]; $nature= $_GET["nature"]; $color[]= $_GET["color"]; $name= $_GET["name"]; $jobtitle= $_GET["jobtitle"]; $Company= $_GET["Company"]; $address1= $_GET["address1"]; $Tel= $_GET["Tel"]; $Fax= $_GET["Fax"]; $Handphone= $_GET["Handphone"]; $Email= $_GET["Email"];

require_once('lib/class.phpmailer.php');

$mail = new PHPMailer(); // defaults to using php "mail()"

$mail->AddReplyTo("[email protected]","rusly");

$mail->SetFrom('[email protected]', 'rusly');

$mail->AddReplyTo("[email protected]","rusly");

$address = "[email protected]"; $mail->AddAddress($address, "rusly");

$mail->Subject = "Starshine Group - Enquiry Form";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->Body = "Contact Us

$first
job : $job
nature : $nature

Product Interest : ";
foreach($color as $k=>$val){
    $mail->Body .= $val.', ';
}
 "First Name : $name
Job Title : $jobtitle
Address : $address1
Company : $Company
Phone Number : $Tel
Handphone : $Handphone
Email : $Email
Fax : $Fax
Thank You!

";

if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo " First Name : $name
Address : $address1
Phone Number : $Tel
Email : $Email
Thank You!


Message sent!
"; }

?>

1 Comment

nice..but when i tick 2 or more checkbox the ouput just one...why?
0
    if($_REQUEST[color]){
        $color=$_REQUEST[color];
    }else{
        $color=array();     
    }
    $totalcolor=implode(",", $_REQUEST[color]);

first to set this on the your page and then requested $totalcolor value its contains all value of the color with , ok go a head.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.