forms - PHP Checkbox Verification Keeper -


i have comment section handling name/phone/comment/etc. have checkbox in form well. error exception produce when checkbox set empty. if boxes checked, , other areas aren't satisfied, can't boxes stay checked while errors thrown elsewhere , page reloaded.

i tried setting values , $response in if statements yes, if 1 box checked, when page reloads boxes checked.

php:

if ($_server["request_method"] == "post") {     if (empty($_post["response"])) {         $responseerr = "response required";     } else {         $response = test_input($_post["response"]);     } }   how prefer respond? choose apply. <span class="error">*      <?php echo $responseerr;?> </span>  <br> <input type="checkbox" name="response" <?php if (isset($response) && $response=="call") echo "checked";?> value="call">call <input type="checkbox" name="response" <?php if (isset($response) && $response=="text") echo "checked";?> value="text">text <input type="checkbox" name="response" <?php if (isset($response) && $response=="email") echo "checked";?> value="email">e-mail <br><br> 

an alternate solution give each checkbox unique name (tel-response, email-response, text-response) , check each individually. sure, means more code, easy implement , manage later on.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -