you can validate the data going into a checkbox, this is what i use
if(!isset($_POST['whatever'][0])) {
$error1.="<font face='Verdana' size='1'>Required!<br />";
}
if ($errcount !=0) {
//displays errors in form boxes
}
else {
$whatever = $_POST['whatever'];
include("databaseconn.php");
$conn = mysql_connect($host, $username, $password) or die(mysql_error());
mysql_select_db($database,$conn) or die(mysql_error());
$query = "INSERT INTO namedtable VALUES ('','$whatever')";
mysql_query($query) or die(mysql_error());
// then do something redirect whatever
<input name="whatever" type="checkbox" id="whatever" value="y" <?php if (!empty($_POST['whatever'])) echo 'checked="checked"'; ?>>
the if(!isset($_POST['whatever'][0])) { checks if the checkbox is just checked.
If you are using a Text box you could use validation like
if(preg_match('/^[0-9_-]{11,}$/i', $_POST['whatever'])){
if you are using numbers , the {11,} is the number of characters req, i use this for valid telephone numbers with no space or
if(preg_match('/^[a-zA-Z0-9_-]{4,}$/i', $_POST['whatever'])){
if you are using numerals and letters upper and lowercase, remove a-z or A-Z accordingly
[a-zA-Z0-9-]this does not alow spaces, but [a-zA-Z0-9 -] does.
see preg_match in the manual for further guidance if needed.
hope this helps a little, keep trying to get the code that works with security for you.