I want a form to remember the user's input whenever an error has occurred. I got this to work using for the text input using:
echo "<input id=\"quote_square\" type=\"text\" name=\"square\" placeholder=\"Square\" value=\"". $_POST['square'] . "\">";
For checkboxes I can't get this to work. I did find this example of how this can be done:
<input type="checkbox" name="subscribe" <?php echo (isset($_POST['opdracht'])?'checked="checked"':'') ?> />
But I'm echoing my entire form into php and saving the checkbox input into an array:
echo "<input id=\"quote_round\" type=\"text\" name=\"round\" placeholder=\"Round\" value=\"". $_POST['round'] . "\">";
echo "<input id=\"quote_square\" type=\"text\" name=\"square\" placeholder=\"Square\" value=\"". $_POST['square'] . "\">";
echo "<label class=\"checkbox\"><input type=\"checkbox\" name=\"opdracht[]\" value=\"Blue\">Blue</label>";
echo "<label class=\"checkbox\"><input type=\"checkbox\" name=\"opdracht[]\" value=\"Black\">Black</label>";
echo "<label class=\"checkbox\"><input type=\"checkbox\" name=\"opdracht[]\" value=\"Red\">Red</label>";
echo "<label class=\"checkbox\"><input type=\"checkbox\" name=\"opdracht[]\" value=\"White\">White</label>";
Can anybody give a suggestion how I can get the checkboxes to save the user's input?