I make a user permission form where multiple checkbox exist when i check a checkbox after submitting the form. Form is not showing the previously checked checkbox please help me. I want that form show previously checked checkbox.
Asked
Active
Viewed 139 times
0
-
3Then please show us your code. – obscure Jun 17 '19 at 09:38
-
1Please refer the [How to Ask guide](https://stackoverflow.com/questions/how-to-ask) for more details on how to ask a question and update your question accordingly with what you have tried so far. – Core972 Jun 17 '19 at 09:39
-
Possible duplicate of [Echo PHP variable as an value of input field](https://stackoverflow.com/questions/36519371/echo-php-variable-as-an-value-of-input-field) – Titulum Jun 17 '19 at 09:40
1 Answers
0
Below are the example code of maintain checkbox value after submitting form
<?php
if (isset($_POST['number']))
{
foreach ($_POST['number'] as $selectednumber)
$selected[$selectednumber] = "checked";
}
?>
<form action="" method="post">
<input type="checkbox" name="number[]" <?php echo $selected['one'] ?> value="one" />one<br />
<input type="checkbox" name="number[]" <?php echo $selected['two'] ?> value="two" />two<br />
<input type="checkbox" name="number[]" <?php echo $selected['three'] ?> value="three" />three<br />
<input type="checkbox" name="number[]" <?php echo $selected['four'] ?> value="four" />four<br />
<input type="submit" name="Submit" value="Submit" />
</form>
So apply on your code and let me know it's helpful or not.

Chetan Kanani
- 308
- 1
- 9