SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru davedibiase's Avatar
    Join Date
    Aug 2001
    Location
    Toronto, Canada
    Posts
    829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Collecting user information via PHP!

    Does anyone know of the PHP built in functions to retrieve user info such as: IP address, browser type, resolution and any other info you can collect about there system.

    I am going to try and implement these functions into making my website a lot easier to fit to specific users browsers with PHP.

    I also wanted to log user specific information. Mostly their IP addresses. Could I do a trace (iplookup) of the IP and have it logged into the database?

    Thanks!
    ||Dave Di Biase||
    ----------------------------------
    "There are 2 secrets in life. 1) Never say everything you know."
    GFXWARS - The ultimate graphics battle!

  2. #2
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Guru davedibiase's Avatar
    Join Date
    Aug 2001
    Location
    Toronto, Canada
    Posts
    829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just used those articles to make my script. The IP and lookup works but I can't seem to get the get_browser() features to work. Also any ideas on how to find screen resolution? Heres my code:

    PHP Code:
    <?
    $IP 
    $_SERVER['REMOTE_ADDR'];
    $HOST gethostbyaddr($IP); 
    print 
    "Your IP address is: ".$IP."<br><br>";
    print 
    "Your host is: ".$HOST;

    $BROW_INFO get_browser();

    $BROWSER $_SERVER['HTTP_USER_AGENT'];
    $BROWSER_NAME $BROW_INFO->browser;
    $PLATFORM $BROW_INFO->platform;
    $TABLES $BROW_INFO->tables;
    $FRAMES $BROW_INFO->frames;

    print 
    "<br><br>You are running ".$BROWSER." (".$BROWSER_NAME.") on ".$PLATFORM."!";
    if (
    $TABLES == "1"){
    print 
    "<br><br>You do support tables!";
    }

    if (
    $FRAMES == "1"){
    print 
    "<br><br>You do support frames!";
    }
    ?>
    ||Dave Di Biase||
    ----------------------------------
    "There are 2 secrets in life. 1) Never say everything you know."
    GFXWARS - The ultimate graphics battle!

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    PHP can't find screen resolution but JavaScript can. I'm not sure how to use JS to get that but a quick post in the JavaScript forums should find what you're looking for

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2001
    Location
    North Wales, UK
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Note that screen resolution is almost meaningless on the Web. Screen resolution isn't the same as browser window size, and making different versions of your page for different resolutions is just making more work for yourself.

  6. #6
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by tfountain
    Note that screen resolution is almost meaningless on the Web. Screen resolution isn't the same as browser window size, and making different versions of your page for different resolutions is just making more work for yourself.
    Hehe, this was exactly what I was about to post.

  7. #7
    SitePoint Guru davedibiase's Avatar
    Join Date
    Aug 2001
    Location
    Toronto, Canada
    Posts
    829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could someone help me with this problem. I am trying to learn how to use the get_browser() function!! the PHP.net tutorial is no help, doesn't even tell you how to actually access the info. Ideas?

    PHP Code:
    <?
    $IP 
    $_SERVER['REMOTE_ADDR'];
    $HOST gethostbyaddr($IP); 
    print 
    "Your IP address is: ".$IP."<br><br>";
    print 
    "Your host is: ".$HOST;

    $BROW_INFO get_browser();

    $BROWSER $_SERVER['HTTP_USER_AGENT'];
    $BROWSER_NAME $BROW_INFO->browser;
    $PLATFORM $BROW_INFO->platform;
    $TABLES $BROW_INFO->tables;
    $FRAMES $BROW_INFO->frames;

    print 
    "<br><br>You are running ".$BROWSER." (".$BROWSER_NAME.") on ".$PLATFORM."!";
    if (
    $TABLES == "1"){
    print 
    "<br><br>You do support tables!";
    }

    if (
    $FRAMES == "1"){
    print 
    "<br><br>You do support frames!";
    }
    ?>
    ||Dave Di Biase||
    ----------------------------------
    "There are 2 secrets in life. 1) Never say everything you know."
    GFXWARS - The ultimate graphics battle!


Bookmarks

Posting Permissions

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