SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    uk
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect based on ip address....

    I'm currently using php to monitor ip addresses of my visitors via an ifarme as the external site I'm using can't access my mysql database....unfortunately because the php is checked in an iframe I am unable to redirect problem user to a "You are barred" page...

    Can this be done with Javascript?

    I'm looking for a script which:

    1)Checks a users ip address...
    2)Compares it to ip addresses held within the script.
    If true redirect to a new page.
    If false continue loading the page as it stands.

    I have 3 ip addresses which need the script needs to compare against.

    I can insert javascript into the page but not php

    I have no understanding of Javascript and would appreciate any assistance you can offer.

    TIA

    Caunton

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why would you use javascript to do this as you can disable javascript thus making the script pointless?

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    uk
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So that puts paid to that idea

    Ok, any suggestions on how this can be achieved...??

    Not that I think the individuals involved would know how to disable anything never mind javascript...

    I think Javascript is the only language I can use on the external site except html which doesn't have the ability to redirect based on ip address...

    Caunton

  4. #4
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately you can't get the user's IP address through Javascript. If your server can handle SSI (Server Side Includes, often available on Apache) you can use the workaround from this page but it will only work if you have SSI support on your hosting:

    http://javascript.internet.com/user-...-filter-2.html

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    uk
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Skunk,
    You are an absolute star....

    This works from within the iframe so I am able to code it into the site from my own domain which does have SSI.

    Thank heavens for these forums.

    Caunton


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
  •