Results 1 to 4 of 4

Thread: PHP Help

  1. #1
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default 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.
    Last edited by ,Jess,; 24-01-2009 at 12:31 PM.
    Vouches
    [x][x]

  2. #2

    Default

    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.
    Last edited by Iszak; 23-01-2009 at 11:36 PM. Reason: spelling

  3. #3
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    Thanks +rep
    Vouches
    [x][x]

  4. #4
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    Quote Originally Posted by Fazon View Post
    Thanks +rep
    Once again iszak got it in a nutshell but you could also do:

    PHP Code:
    if (!$_SERVER['var']!)
    {




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •