PHP keep checkbox checked after submitting form
If the submitted value is not empty, then add the checked="checked"
attribute to the checkbox:
<input type="checkbox" name="txtCheck" value="1" <?php if (!empty($_POST['txtCheck'])): ?> checked="checked"<?php endif; ?> />
You can however leave the value
attribute intact.
change
<input type="checkbox" name="txtCheck" value="<?php echo $_POST['txtCheck'];?>" /><br />
to
<input type="checkbox" name="txtCheck" value="your value" <?php if(isset($_POST['txtCheck'])) echo "checked='checked'"; ?> /><br />
this will keep checkbox checked..