Checkbox in emailForm.php

3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 16, 2013   (RSS)

By gregThomas - July 16, 2013

Hi Tim,

The issue is that when a browser submits a form if a checkbox is not ticked it doesn't send a value at all as opposed to sending an empty or negative value.  I would check if values have been sent, and then create some variables to add to your e-mail. Something like this should work:

Creating the variables

<?php

$director =  (@$_REQUEST['director'])? 'Yes' : 'No' ;
$trustee  =  (@$_REQUEST['trustee'])? 'Yes' : 'No' ;
$business =  (@$_REQUEST['business'])? 'Yes' : 'No' ;
$all      =  (@$_REQUEST['all'])? 'Yes' : 'No' ;

?>

Add the strings to your e-mail

Director:  {$director}
Trustee:  {$trustee}
Business:  {$business}
All:  {$all}

Let me know if you have any questions. 

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Toledoh - July 16, 2013

perfect - thanks Greg!

Cheers,

Tim (toledoh.com.au)