mardi 17 décembre 2019

In PHP how to Keep the values in the form for check box?

This is my HTML code

<label>Subject : </label>
<label><input type="checkbox" name="subject" id="subject[]" value="Maths"/>Maths</label>
<label><input type="checkbox" name="subject" id="subject[]" value=English"/>English</label>
<label><input type="checkbox" name="subject" id="subject[]" value="Tamil"/>Tamil</label>

and this is php code

<label>
<input type="checkbox" name="subject" id="subject[]" <?php if (isset($_POST["subject"]) && $_POST["subject"]=="Maths") echo "checked";?> value = "Maths"/>Maths
</label>
<label>
<input type="checkbox" name="subject" id="subject[]" <?php if (isset($_POST["subject"]) && $_POST["subject"]=="English") echo "checked";?> value = "English"/>English
</label>
<label>
<input type="checkbox" name="subject" id="subject[]" <?php if (isset($_POST["subject"]) && $_POST["subject"]=="Tamil") echo "checked";?> value = "Tamil"/>Tamil
</label>

but is not working.




Aucun commentaire:

Enregistrer un commentaire