如何检查复选框是否被选中php



这是我的复选框和按钮的html代码

<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>

我想检查复选框是否被选中,如果是,将输入写入我的文件。
我尝试使用isset函数,但它不工作任何其他建议?

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>

最新更新