Validating IDs in php using intval ()?
Posted: Mon Aug 27, 2012 9:49 am
Hi Everyone,
I'm trying to figure out the correct syntax when trying to validate this line of code using intval ().
Below is what I think is the correct syntax but I''m getting an error message and I'm not sure what I'm doing wrong.
http://whatsmyowncarworth.com/more-prac ... .php?id=10
Error message "Missing Data to Run"
(I think this is the correct way but my syntax is wrong. What's the correct syntax?)
Any help would be appreciated! Thanks everyone!
I'm trying to figure out the correct syntax when trying to validate this line of code using intval ().
Code: Select all
$id = ereg_replace("[^0-9]", "", $_GET['id']); // filter everything but numbers for security
if ($id == "") {
echo "Missing Data to Run";
exit();
}http://whatsmyowncarworth.com/more-prac ... .php?id=10
Error message "Missing Data to Run"
(I think this is the correct way but my syntax is wrong. What's the correct syntax?)
Code: Select all
$id = $_GET['id'] = 1;
if (filter_var($id, FILTER_VALIDATE_INT) !== false)
{
echo "Missing Data to Run";
exit();
}