How do I add a check box to the WSM Registration form?

4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 29, 2012   (RSS)

By Perchpole - May 28, 2012

Hello, All -

The title of this post really says it all. I want to add a checkbox to the registration form which users must activate to demonstrate their compliance with the terms & Conditions of the site.

I simply copied one of the other lines of code and changed the input type to checkbox...

<input type="checkbox" name="compliance" value="<?php echo htmlspecialchars(@$_REQUEST['compliance']); ?>" />

...then added a new line to the error checking code...

if (!@$_REQUEST['compliance']) { $errorsAndAlerts .= "You must agree to abide by our Terms & Conditions!<br/>\n"; }

...but none of this seems to work.

The code does not seem to recognise when the box has been checked - which in turn generates an error message.

:0/

Perch

Re: [Perchpole] How do I add a check box to the WSM Registration form?

By Perchpole - May 28, 2012

I did this...

<input type="checkbox" name="compliance" value="1" />

...and this...

if (@$_REQUEST['compliance']!='1') { $errorsAndAlerts .= "You must agree to abide by our Terms & Conditions!<br/>\n"; }

I don't know if it's right but it appears to work now.

Is there a better solution?

Perch

Re: [Perchpole] How do I add a check box to the WSM Registration form?

By Jason - May 29, 2012

Hi Perch,

Your second solution is fine. It can also be written as:

if (!@$_REQUEST['compliance']) { .. }

The reason this didn't work the first time was the value you were giving your check box was the current value of @$_REQUEST['compliance']. When you go to the page, this value is empty, so your check was failing regardless of whether they checked the box or not.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/