Hi all, am trying to use bootstrap switch in my form. Am at a lost as to how to get the value of


from that field and insert it into mysql db, here is my code...

div class="onoffswitch">
    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
    <label class="onoffswitch-label" for="myonoffswitch">
        <div class="onoffswitch-inner"></div>
        <div class="onoffswitch-switch"></div>

Recommended Answers

All 6 Replies

Member Avatar

A tester...

    echo "on";
    echo "off";

Thanks for your prompt reply...
but how do i get the values into this query :

$query ="INSERT INTO sre_log_remind VALUES('','$tag','$s_veration')";


so that i can insert the values 'ON' or 'OFF' in to the db?

Member Avatar

You should save the values as a tinyint(1) - 0 or 1.

    $switch = 1;
    $switch = 0;

Or a one-liner...

$switch = (isset($_POST['onoffswitch'])) ? 1 : 0;


$query ="INSERT INTO sre_log_remind VALUES(NULL,'$tag',$switch)";    
commented: perfect solution +1

thanks Diafol, i will am giving it a try. Your contributions are always rich and deep. How long have you been programming...?

Member Avatar

Hmm, difficult to say - I've been 'playing' at programming for about 20 years. Only started to make it a serious hobby about 5 years ago. I'm not a professional programmer - that aspiration - unfortunately - is beyond my abilities - but I do enjoy playing.

LOL, thanks for your help man, it worked perfectly.Am working hard, so i can be of help to others, Greate Work Man...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.