-
PHP Help
Ay,
I have a login script. Everytime a user logs in, it records their IP. In order to ensure that they aren't using a proxy to hide their IP, I want to be able to record their real IP. Most proxies use the $_SERVER['HTTP_X_FORWARDED_FOR'] header from what I know so I need a PHP script that checks to see if that header (or $_SERVER['VIA'];) exists and if it does, save that IP instead (I can code that last one). Is there a way to check if a SERVER var exists?
Thread moved from Designing & Development by ,Jess, (Forum Super Moderator): Please post in the correct section.
-
Well you can do it two ways, but ones faster than the other.
PHP Code:
if (isset($_SERVER['var']))
{
}
or
PHP Code:
if (array_key_exists('var', $_SERVER))
{
}
you could also do
PHP Code:
if (empty($_SERVER['var']) === false)
{
}
The first one Is faster than the second and I'm not sure about the third.
-
-
Quote:
Originally Posted by
Fazon
Thanks +rep
Once again iszak got it in a nutshell but you could also do:
PHP Code:
if (!$_SERVER['var']!)
{
}