On my website, I have a page where my visitors can click on PHP links to download files. At the same time, my PHP also retrieves basic information from this download us PHP like the user IP address and sends an email to us all in the background.
So, my question is this. Is there away to retrieve my visitors' domain name using their IP address from which they are requesting information if it is possible? I am running ClearOS and PHP 5.4
I did read that you have to set up your webserver for this especially enabling hostnamelookup on inside httpd.conf
I simply want to $_SERVER["REMOTE_HOST"] for my visitor's domain name.
Any hints or clues will be greatly appreciated. Thanks.
So, my question is this. Is there away to retrieve my visitors' domain name using their IP address from which they are requesting information if it is possible? I am running ClearOS and PHP 5.4
I did read that you have to set up your webserver for this especially enabling hostnamelookup on inside httpd.conf
I simply want to $_SERVER["REMOTE_HOST"] for my visitor's domain name.
Any hints or clues will be greatly appreciated. Thanks.
In PHP Engines
Share this post:
Responses (4)
-
Accepted Answer
-
Accepted Answer
It is possible you do a reverse DNS lookup which returns the PTR record for the IP. There is only one per IP. If lots of domains use a single IP, you can't do a reverse lookup on that as it is different. PTR records are set by the ISP and some, especially business ones, allow you to change them. Many IP's done have them. Others use generic ones. -
Accepted Answer
Hi Nick,
Well, in my internet research on this, I kept getting told that it is nearly IMPOSSIBLE to do this for each server ip address it could be pointing at more than one domain name; retrieving domain name for a server from its ip address. I understood the reason why. However, there is a PHP environmental element that you can request from the visitor's server that gives you the name (Domain Name) of the server if possible; $_SERVER["SERVER_NAME"].
To my surprise, it returned EXACTLY what I was looking for a domain for the server like www.example.com.
Just putting this out here just in case someone is looking for something similar solution or an answer.
Thank you for the reply Nick. -
Accepted Answer
Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here.
Register Here »