I have some links structured as follows...
http://domain.com?problem_id=23&course_id=4
The expected values from the GET "fields" (problem_id and course_id) are to be integers. Can I validate this data by simply saying...
if (is_numeric($_GET['problem_id'])){
//It's safe, so do stuff.
} else {
echo 'It appears you submitted a problem incorrectly. Please contact us for assistance';
exit;
}
Or is this still open to nastiness like sql injection, etc.?
PROPOSED SOLUTION
$int_problem_id = (int) $_GET['problem_id'];
if (ctype_digit($int_problem_id)){
//It's safe, so do stuff.
} else {
echo 'It appears you submitted a problem incorrectly. Please contact us for assistance';
exit;
}