Jump to content

Checkbox Values?


johnnys
Go to solution Solved by Barand,

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
Share on other sites

  • Solution

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.