Results 1 to 5 of 5

Thread: php get domain from referrer

  1. #1
    Join Date
    Mar 2010
    Posts
    71

    php get domain from referrer

    Hi all,

    I am in little bit trouble and need to know something about the manipulation of referrer, In such scenario, can somebody show me how to take the referrer, and strip out http:// and the page part of the URL. Entirely, I want left is the domain like as www.Techarena.in ...

    Thanks !!
    Last edited by Seducer; 11-05-2010 at 12:48 PM.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    php get domain from referrer

    If you need to access the domain name of the referrer then you can create a script in PHP which can made you able to get the domain name, I am going to show you the script written here and I hope it would be much helpful for you, please take a look here ..

    Code:
    <?php
    if (isset($_SERVER['HTTP_REFERER']))
    {
          $array = parse_url($_SERVER['HTTP_REFERER']);
          echo $array['host'];
    }
    
    ?>

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: php get domain from referrer

    Referrer is the URL from where the visitor get access on the page. If you are currently accessing the page by clicking a link from google.com then google URL would be referrer for you for this page. We can get the referrer by using PHP. This is useful for the webmasters to find out that from where the traffic for the site is gathering . Which advertisement campaign is getting higher views and which is not. We will also know the keywords used by the visitors in so mnay search engines to arrive at the site. Here is the easy script to find out the referrer in PHP
    Code:
    $ref=@$HTTP_REFERER;
    
    echo "<font face='Verdana' size='3'><b>Referrer of this page  = $ref </b>";

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: php get IP from referrer

    We can find out the IP address of any user visiting on the page by using PHP. Finding the IP address is very important need for several scripts where we store the members or visitors information . For security causes, we can store IP address of our visitors who are committing any purchases or recording the geographical location of the visitor can be performed this way. Some time based on the IP address, we can redirect the browser to another areas of the web site. There are several applications using this and here is the PHP code to know the IP address of any visitor to the site.
    Code:
    $ip=@$REMOTE_ADDR;
    echo "<b>IP Address= $ip</b>";
    The above code would evaluate the result in this for with the visitors IP address= 122.182.10.138..

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: php get domain from referrer

    We can gather IP address of the guests by using Request object and its ServerVariable pairs. IP address of the user is needed in several applications for separate purposes. IP address are gathered and logged for security purposes on separate occasions like credit card process, member signup time etc. From the IP address we can find out the location of the guest. However we will prevent ourselves only to know how to gather IP address of the guest browser from the HTTP header information.

    In PHP we can find out the IP address and details are here. In ASP programming as we will use the http header information so it is good to read the whole article on http header and request object and is freely available on the net. We will use http header name REMOTE_ADDR or HTTP_HOST to find out the IP address. Here is the code.

    <%= Request.ServerVariables("HTTP_ADDR")%>


    The above IP value ( data ) can be used for several purposes.

Similar Threads

  1. Replies: 7
    Last Post: 28-12-2010, 10:05 PM
  2. Return the title, URL and referrer in JavaScript document
    By KALLIYAN in forum Software Development
    Replies: 3
    Last Post: 10-12-2009, 12:32 AM
  3. Replies: 1
    Last Post: 16-09-2009, 10:11 AM
  4. backup domain controller in a small business server 2003 domain
    By Ashish Goenkar in forum Small Business Server
    Replies: 4
    Last Post: 31-01-2009, 12:16 AM
  5. Replies: 1
    Last Post: 19-06-2008, 01:58 AM

Tags for this Thread

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
  •  
Page generated in 1,727,092,953.37718 seconds with 17 queries