We should check the parameter and validate it.
If it is set
if ( isset($_GET['id']) ) { // ok it is set. }
Now I also check if it is empty or not;
If it is not empty
if ( isset($_GET['id']) && !empty($_GET['id']) ) { // ok it is set and not empty }
If you know the parameter must be integer, than lets check
If it is a valid number.
if ( isset($_GET['id']) && !empty($_GET['id']) && is_numeric($_GET['id']) ) { // ok it is set, not empty, and a number, get it; $id = trim($_GET['id']); }
Finally we get our parameter safely in PHP.
No comments:
Post a Comment