简体   繁体   中英

How to check if checkbox is checked php

This is html code for my checkbox and button

<form> 
     <input type="checkbox" id="DNA" name="DNA" value="checkox_value">
     <button type="button" name="submit" onClick="search()" id="sim_btn" class="btn btn-primary">Start Simulation</button>
</form>

I want to check if checkbox is checked and if yes write the input to my file.
I tried using the isset function but it doesn't work any other suggestions?

if(isset($_POST["DNA"])) { 
        $input3 = "signal(f).";
        fwrite($handleStoryFile, $input3 . PHP_EOL); 
    }  

 <!DOCTYPE html> <html> <body> <form action="#" method="post"> <input type="checkbox" id="DNA" name="DNA" value="checkox_value"> <button type="submit" name="submit" id="sim_btn" class="btn btn-primary">Start Simulation</button> </form> <?php if(isset($_POST["DNA"])) { echo 'test'; } ?> </body> </html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM