How to verify this checkbox is checked?

Actually I want to include a file if the checkbox is checked

<?php
$checked = get_option('automatic') ? "checked='checked'" : "";
echo "<input type="checkbox" name="automatic" $checked />";
?>

if(get_option('automatic') == 'checked')) ( require_once 'myfile.php'; )

This form is in a plugin option page

4 Answers
4

<?php
echo "<input type="checkbox" name="automatic" value="1" ".checked(1, get_option('automatic'))." />";

if (get_option('automatic') === '1') { require_once 'myfile.php'; }
?>

Leave a Comment