This is my code:
<form...>
<input type='checkbox' value='1' name='speak_langs[]'>I speak English
<input type='checkbox' value='2' name='speak_langs[]'>I speak German
<input type='checkbox' value='3' name='speak_langs[]'>I speak French
<input type='checkbox' value='4' name='speak_langs[]'>I speak Spanish
<input type='checkbox' value='5' name='speak_langs[]'>I speak Swedish
...
</form>
mysql_query("UPDATE user_table SET speak_langs='" . mysql_escape_string(implode(", ", $speak_langs)) . "' where user_id='$id'");
Is there any way how to control the values of checkboxes?
For example, when user submits this form and he/she checked that he/she speaks English and Spanish... The script will insert into database:
1,4
That's correct.
But someone can create and submit a form like this:
<form action=myserver.com/submit.php>
<input type='checkbox' value='f**k off' name='speak_langs[]'>I speak English
<input type='checkbox' value='4' name='speak_langs[]'>I speak Spanish
In this case the script will insert into database:
f**k off, 4
I need some way to check that all values of checked boxes are only numbers between 1 and let's say 10.
It's easy if there is only 1 value and I can use for example is_numeric or something like that, but how to do it with checkboxes...?
Thank you.