Help with PHP and checkboxes


Posted on 16th Feb 2014 07:03 pm by admin

I am posting this for a friend of mine, i wrote a small script for her to process her form data to an email but in testing i am having trouble getting the checkbox data to display in the email it sends. if you select multiple checkboxes it emails only the last checked box.

the following is the html code:

Code: <td><p>Job Description:</p></td>
<td><label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="Drywall" id="jobdescription_0" />
Drywall</div>
<div align="left"></div>
<label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="Insulation" id="jobdescription_1" />
Insulation</div>
<div align="left"></div>
<label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="Taping" id="jobdescription_2" />
Taping</div>
<div align="left"></div>
<label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="Texture" id="jobdescription_3" />
Texture</div>
<div align="left"></div>
<label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="Stucco" id="jobdescription_4" />
Stucco</div>
<div align="left"></div>
<label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="T-Bar" id="jobdescription_5" />
T-Bar</div>
<div align="left"></div>
<label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="Custom Ceilings" id="jobdescription_6" />
Custom Ceilings</div>
<div align="left"></div>
<label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="Steel Stud Framing" id="jobdescription_7" />
Steel Stud Framing</div>
<div align="left"></div>
<label> </label>
<div align="left">
<input type="checkbox" name="job_description[]" value="Bulk Heads" id="jobdescription_8" />
Bulk Heads</div>
and this is the php code:

Code: <?php

date_default_timezone_set('America/Edmonton');

$yourEmail = "test@yahoo.ca";
//The Email Address Form Results Will Be Sent To. Change to your email.

$subject = "Online Job Requests";
//This will be displayed in your Email Subject line. Edit as needed.

$body = "Name: $_REQUEST $name n Email Address: $_REQUEST $email n Phone: $_REQUEST $phone n Job Type: $_REQUEST $job_type n Job Description: $_REQUEST $job_description n";


$timestamp = date("n/j/Y, a\t g:i a T");


$thankyousubject = "Request Submitted Successfully n on n $timestamp";
//This will be displayed after a submission. Edit to suit your needs. The n represent page breaks.

$thankyoumsg = "Thank you $_REQUEST[name] we have recieved your information. We will contact you soon.";
//This will be displayed after a submission. Edit to suit your needs.

$job_description ="";
foreach($_REQUEST["job_description"] as $value) {
$job_description .= "$valuen";
}


?>
<?php
mail($yourEmail, $subject, $body, "From: $_REQUEST[$name] < $_REQUEST[$email] >");
print "<CENTER><B><body bgcolor='#2c2c2c'><font color='#FFFFFF'> $thankyousubject </B></CENTER>

<center>$thankyoumsg</center><BR><BR><CENTER>

</font><A HREF="http://www.shekinteriors.com" TARGET="_top"><IMG SRC="http://www.shekinteriors.com/formbanner.gif" WIDTH="600" HEIGHT="100" ALT="Return to Shek Interiors Ltd" BORDER="0"></A></CENTER></body>"

?>
i thought the
Code: $job_description ="";
foreach($_REQUEST["job_description"] as $value) {
$job_description .= "$valuen";
}
would help this but the mail it generates looks like the following:

Code: Name: Array test525
Email Address: Array dtyjdtj@ftdhdxf.com
Phone: Array 67586785
Job Type: Array New Commercial
Job Description: Array Bulk Heads
could someone please help me figure this out. i'm not super familiar with php and it's driving me bonkers

No comments posted yet

Your Answer:

Login to answer
166 Like 42 Dislike
Previous forums Next forums
Other forums

Confused with Loop
guys, i got confused with Looping...this is the case

I have 3 stocks, let say "Stock A&q

the problem with str_replace
$str="hahahahahahahahahahahahahaha";
$nn=1;
$str=str_replace('ha','MyGod',$str,$nn);

Validating time
Hi Guys

what do you think of the following approach to validate a 24hour time:

http://

Strange PHP/mySQL error ... am I just tired?
Code: <?

## CONNECT TO DB FUNCTION!
function ConnectTo($db2con)
{
$hostNam

Disable Scrollbar in TableControl
Hello everbody,

please can anybody help me - outherwise i'm going to become desperate :P<

Baffled by Undefined Index in Simple Array: Please Help!
Hello. I have a form which posts an array to this script. However, I can't seem to access the values

Modal Popup Help
Hi guys, I have a modal popup with an iframe. How can i send data from a label or textbox to the ifr

Agency Business Process
Hi,

I don’t understand the process of the agency business in SAP.

In my

why does my session end?
my connect.php starts the session just so you know
i can navigate arround my site fine except whe

Getting Resource id #11 while trying to connect..
So i tried using "DEFINE" for the first time and im using the variables i defined to conne

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash