how to get checkbox results to be delivered via php forrm handler

hello,
I have a form that works fine using a php form handler. When i add in a set of checkboxes, I can't seem to get the checkbox array (requirements[])  to be delivered in the email sent by the form handler. Below is the form code and also the php form handler.

thanks for your time
<form method="post" action="sendmail2.php" onSubmit="return check_send(this);" >
<input type="hidden" name="subject" value="website enquiry">


<div id="FormCol">

<p>Please complete the form below and click on submit. 
<br />We will contact you shortly to discuss your requirements.<br /><br />

 <span>Fields marked * must be filled in.</span></p>

<label id="name">Name *</label>
<input tabindex="1" name="name" id="name" type="text" class="textField" >

<label id="company">Company *</label>
<input tabindex="2" name="company" id="company" type="text" class="textField" >

<label id="website">Website</label>
<input tabindex="3" name="website" id="website" type="text" class="textField" >

<label id="email">Your Email *</label>
<input tabindex="4" name="email" id="email" type="text" class="textField" >
     
<label id="telephone">Telephone *</label>
<input tabindex="5" name="telephone" id="telephone" type="text" class="textField" >


<label id="requirements">Your requirements (please tick)</label>

<div id="Checkboxes">



<input name="requirements[]" value="Branding" type="checkbox" tabindex="6"  
id="Branding"><p>Company branding including; logos, stationery, packaging, signage</p><br />

<input name="requirements[]" value="Website" type="checkbox"  tabindex="7" 
id="Website"><p>Website</p><br />

<input name="requirements[]" value="Planning" type="checkbox"  tabindex="8" 
id="Planning"><p>Marketing planning and execution</p><br />

<input name="requirements[]" value="PrintedMedia" type="checkbox"  tabindex="9" 
id="PrintedMedia"><p>Printed media including; sales and marketing collateral, brochures, newsletters</p><br />

<input name="requirements[]" value="ElectronicMedia" type="checkbox"  tabindex="10" 
id="ElectronicMedia"><p>Electronic media including company videos and online demo's</p><br />

<input name="requirements[]" value="SalesCampaigns" type="checkbox"  tabindex="11" 
id="SalesCampaigns"><p>Sales lead campaigns</p><br />

<input name="requirements[]" value="EventManagement" type="checkbox"  tabindex="12" 
id="EventManagement"><p>Event management</p><br />

<input name="requirements[]" value="PR" type="checkbox"  tabindex="13" 
id="PR"><p>PR campaigns</p><br />

<input name="requirements[]" value="CustomerResearch" type="checkbox"  tabindex="14" 
id="CustomerResearch"><p>Customer research</p><br />

<input name="requirements[]" value="Other" type="checkbox"  tabindex="15" 
id="Other"><p>Other</p><br />


</div>



<label id="comments">Additional Comments</label>
<textarea tabindex="16" name="comments" id="comments" rows="3" wrap="VIRTUAL"></textarea>

<br />


<input name="submit" type="image" id="sendButton" tabindex="17" value="Submit" src="Images/submit.gif" width="78" height="35">


</div>
<!--  -->
</form>



<?php
$from = 'Website'; 

$to = 'hello@email.co.uk';
 
$name        = $_POST['name'];
$company      = $_POST['company'];
$email 		= $_POST['email'];
$telephone       = $_POST['telephone'];



$requirements = $_POST['requirements'];



$comments        = $_POST['comments'];

 
if(($name=="") || ($company=="") || ($email=="") || ($telephone=="")) {
        header( "Location: error.html" );
}
else {
        $msg="name: " . $name ."\n";
         $msg.="company: " . $company ."\n";
		 $msg.="email: " . $email ."\n";
       	$msg.="telephone: " . $telephone ."\n";
		
		
	$msg.="requirements: " . $requirements ."\n";
		 
		 
		 $msg.="comments: " . $comments ."\n";

         
        if(mail("$to","Hive Marketing web enquiry",$msg,"From: $from", "-f$from")) {
           /*If sent direct customers to thankyou page */
           header( "Location: thanks.html" );
        }
        else {
           /* If there is an error display an error message */
           header( "Location: error.html" );
        }
}


?>

Open in new window

jonsmithgraphicsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ludofulopCommented:
hello, try to change this line:
$requirements = $_POST['requirements'];
to
$requirements = implode(", ", $_POST['requirements']);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KalpanCommented:
Please use the below code snippet...

use it like this...

if($_POST['requirements1'])
                echo $_POST['requirements1'];
        if($_POST['requirements2'])i
                echo $_POST['requirements2'];


thanks, Kalpan
<?php
if($_POST['submit']){
        if($_POST['requirements1'])
                echo $_POST['requirements1'];
        if($_POST['requirements2'])i
                echo $_POST['requirements2'];
        echo $_POST['name'];
}else{
?>

<form method="post" action="testcheckbox.php"  >
<input type="hidden" name="subject" value="website enquiry">


<div id="FormCol">

<p>Please complete the form below and click on submit.
<br />We will contact you shortly to discuss your requirements.<br /><br />

 <span>Fields marked * must be filled in.</span></p>

<label id="name">Name *</label>
<input tabindex="1" name="name" id="name" type="text" class="textField" >

<label id="company">Company *</label>
<input tabindex="2" name="company" id="company" type="text" class="textField" >

<label id="website">Website</label>
<input tabindex="3" name="website" id="website" type="text" class="textField" >

<label id="email">Your Email *</label>
<input tabindex="4" name="email" id="email" type="text" class="textField" >

<label id="telephone">Telephone *</label>
<input tabindex="5" name="telephone" id="telephone" type="text" class="textField" >


<label id="requirements">Your requirements (please tick)</label>

<div id="Checkboxes">

Open in new window

0
jonsmithgraphicsAuthor Commented:
hi thanks for the quick response!

so if my checkboxes were:

<input name="requirements[]" value="Branding" type="checkbox" tabindex="6"  
id="Branding">Company branding including; logos, stationery, packaging, signage<br /><br />

<input name="requirements[]" value="Website" type="checkbox"  tabindex="7"
id="Website">Website<br /><br />

then i would have the php like this:


if($_POST['requirementsBranding'])
                echo $_POST['requirementsBranding'];
        if($_POST['requirementsWebsite'])i
                echo $_POST['requirementsWebsite'];


as each checkbox has a name rather than a number as you showed, would that be correct?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

KalpanCommented:
yes, correct...exactly....it will show the value as Branding coz you have value="Branding" in below tag...

<input name="requirementsBranding" value="Branding" type="checkbox" tabindex="6"  
id="Branding">Company branding including; logos, stationery, packaging, signage<br /><br />


thanks, Kalpan
0
ludofulopCommented:
guys...are you still discussing the question, or am i missing something ?
0
jonsmithgraphicsAuthor Commented:
hi I am trying with both your suggestions now, watch this space....
0
jonsmithgraphicsAuthor Commented:
thanks very much to you both but ludofulop wins as it took just the one line change to get it working!

nice one : )
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.