Undefined Index Issue, email template placeholder using check box

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 1, 2018   (RSS)

By daniel - October 30, 2018

Hi Jerry,

Checkboxes are not "passed through" form submissions if they are not checked, so an additional step will need to be taken to handle them on the processing end. There are two main options:

First, you can silence errors by prepending the values with @ (e.g. @$_REQUEST['more_than_one_location_for_practice']) like they are in the $addLink definition. The result will be the same (passing through empty values) but it will prevent the errors.

If you want a bit more control over how these values are handled, you can check for the existence of the checkbox and create a new variable with the desired values. Something like this:

$moreThanOneLocation = 0;
if (isset( $_REQUEST['more_than_one_location_for_practice'] )) {
  $moreThanOneLocation = 1;
}

$moreThanOnePractitioner = 0;
if (isset( $_REQUEST['more_than_one_practitioner_in_practice'] )) {
  $moreThanOneLocation = 1;
}

You can replace 0/1 if you'd prefer something else, and then update the placeholder arrays to use the new variables.

An additional thing I noticed, there appear to be spaces before the "=" sign in the last two lines of the $addLink definition. These spaces are likely to cause issues when trying to access these values on the page being linked to, and should probably be removed:

$addLink .= "&more_than_one_location_for_practice=" .urlencode(@$_REQUEST['more_than_one_location_for_practice']); 
$addLink .= "&more_than_one_practitioner_in_practice=" .urlencode(@$_REQUEST['more_than_one_practitioner_in_practice']);

Let me know if you have any more questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

By gkornbluth - November 1, 2018 - edited: November 1, 2018

Thanks Daniel,

Appreciate the help.

Everything seems too be working as planned now.

I've revised my code above to indicate the changes.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php