What’s the proper way to sanitize checkbox value sent to the database

I would use the filter_var() function. It has some predefined filters that you can use depending on what kind of data you are expecting such as string, number, etc.

So to sanitize for a number:

$sanitizedNum = filter_var($yourVar, FILTER_SANITIZE_NUMBER_INT);

For a string you would just change “_NUM_INT” to “_STRING”.

Wrap those in a custom function then.