PHP $ _GET variable check

I have code that checks the say, var value in a link.

Http://www.blah.com/index.php?var=

But when such a link is sent to the server, it returns a database error, since var is not set. I tried isset (which is set so as not to stop it), but! Empty does not stop passing var to the database.

This is the code

 if(isset($_GET['id']) && !empty($_GET['id'])){ $id = mysql_prep($_GET['id']); .... } 

Any help?

+4
source share
1 answer
 $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; if($id){ $id = mysql_prep($id); .... } 
+8
source

Source: https://habr.com/ru/post/1434861/


All Articles