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™"> YK GI ZincCoat™</td>
<td><in开发者_开发问答put type="checkbox" name="color[]" value="YK ColourCoat™"> YK ColourCoat™</td>
</tr>
<tr>
<td><input type="checkbox" name="color[]" value="YK WarnaCanggih™ ColourCoat "> YK WarnaCanggih™ ColourCoat </td>
<td><input type="checkbox" name="color[]" value="YK Self Cleaning™ ColourCoat"> YK Self Cleaning™ 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("ruslyrossi46@gmail.com","rusly");
$mail->SetFrom('ruslyrossi46@gmail.com', 'rusly');
$mail->AddReplyTo("ruslyrossi46@gmail.com","rusly");
$address = "ruslyrossi46@gmail.com";
$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>";
}
?>
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>
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("ruslyrossi46@gmail.com","rusly");
$mail->SetFrom('ruslyrossi46@gmail.com', 'rusly');
$mail->AddReplyTo("ruslyrossi46@gmail.com","rusly");
$address = "ruslyrossi46@gmail.com"; $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!
"; }
?>
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.
精彩评论