Jump to content

Checkbox Values?


johnnys

Recommended Posts

Hi all,

 

I need some help with a checkbox I have on my web form.

 

Basically I have a checkbox saying 'click here if you need blah blah' - this successfully sends a '1' value to my sql db if checked, and a '0' value if not checked.

 

What I want to do is email this form data to the user, but instead of displaying in the email 'click here if you need blah blah = 1' , I would like 'click here if you need blah blah = Yes'

 

Below is code of my html form

              <label class="checkbox"> 
 
                <input type="checkbox" id="wallbox" value="1" name="wallbox">

                If yes, please tick the box and fill in the details below.

              </label>

Below id code from my php page which emails form to user

        if(isset($_REQUEST['wallbox']) && $_REQUEST['wallbox']==1 ){

           $wallboxReqd=1; 

        }else{

            $wallboxReqd=0;

        }

My sql db has a field tinyint for wallboxReqd, does this need to be changed to a varchar along with the input type of my html form?

 

Hope this makes sense,

 

Thanks again advance to anybody that can help.

 

J

 

Link to comment
https://forums.phpfreaks.com/topic/279073-checkbox-values/
Share on other sites

If I were you I'd stick with a tinyint with values 0 or 1.

 

However, if you want 'Yes' or 'No' (which then gives complications of testing for ' yes' or 'Yes' ) then

 

 

$wallboxReqd = isset($_REQUEST['wallbox']) ? 'yes' : 'no';

 

and you will need to change the field type in the db table

Link to comment
https://forums.phpfreaks.com/topic/279073-checkbox-values/#findComment-1435557
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.