Here's a php code
if(isset($_GET['id'])) {
//do something
} else {
redirect('index.php'); //redirect is a function
}
Now if id is set (ex: index.php?id=12) then the action is performed but if id is not set (ex: index.php?id=) this shows an error, how to overcome this...??
How to determine id is an integer and it's not empty and then perform the specific action....
Edited
Thank you all for your answers but i am still getting that error...
if(isset($_GET['id'])) { // I implemented all these codes but still....
$user= User::find_by_id($_GET['id']);
// Database Classes Fetches user info from database
}
else {
redirect('index.php'); //redirect function
}
If the id is 1 or greater than 1 then the script executes perfectly. ( index.php?id=1 )
But id i set id as noting i get an error i..e index.php?id=
The code should automatically redirect user to the index.php page instead of showing an error.....
ERROR : Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1