johnnys Posted June 12, 2013 Share Posted June 12, 2013 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted June 12, 2013 Share Posted June 12, 2013 Tinyint is fine. BTW, only checked checkbox values are posted. Quote Link to comment Share on other sites More sharing options...
johnnys Posted June 12, 2013 Author Share Posted June 12, 2013 Thanks for the reply, I'm not exactly sure what that means but I'll go do some research Quote Link to comment Share on other sites More sharing options...
Barand Posted June 12, 2013 Share Posted June 12, 2013 You can just do this (if it is set then it must have been checked) $wallboxReqd = isset($_REQUEST['wallbox']) ? 1 : 0; Quote Link to comment Share on other sites More sharing options...
johnnys Posted June 12, 2013 Author Share Posted June 12, 2013 thanks, though when I remove the old code and replace is with what you provided it still sends a value of '1' or '0'. how do I send a 'yes' or 'no'? 1 being yes and 0 being no. thanks Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted June 12, 2013 Solution Share Posted June 12, 2013 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.