mardi 23 mai 2017

PHP - Saving checkbox with submit button

I am attempting to build a checklist in which you will be able to select / deselect multiple checkboxes and save them to the page using a submit button.

Below is the code I am working with:

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type="submit" value="Save"/>
    <ul>
        <li><input type="checkbox" />Tickets</li>
            <ul>
                <li><input type="checkbox" checked />Person 1's ticket</li>
                <li><input type="checkbox" checked />Person 2's ticket</li>
                <li><input type="checkbox" />Person 3's ticket</li>
                <li><input type="checkbox" />Person 4's ticket</li>
            </ul>
</form>

I cannot seem to get the checkboxes to hold the data after the page is refreshed.

Upon clicking save I would like the page to reload and the checkboxes to hold their data.

I am trying to keep this quite simple, so the least amount of code, the better. Everything I am able to find requires the use of jQuery or databases.

Any assistance is greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire