how to sanitize checkbox input?

Be sure to set the value in your markup. You should have.

<input type="checkbox" name="changeposition" value="yes" />

Then, I’d suggest using sanitize_key() to sanitize.

Keys are used as internal identifiers. Lowercase alphanumeric
characters, dashes and underscores are allowed.

Think of the word yes, as a key. That’s what you’re expecting is a lowercase alphanumeric value.


See also: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox

If the value attribute was omitted, the submitted data would be given a default value of on, so the submitted data in that case would be subscribe=on.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)