I searched for google and got few codes but I am not able to put them in my site. I want a free code that detects Browser, IP and Hostname of the visitor and display is. I am total newbie so please give me the code in a manner that would be just copy paste ready Thank You.
to get the IP <?php echo $_SERVER['REMOTE_ADDR']; ?> get the browser <?php echo $_SERVER['HTTP_USER_AGENT']; ?> hmm for the third one (hostname). i dont know wat this is.. give some example of it?
Here is the script with all your needs. <?php if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') ) { if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') ) { $browser = 'Netscape (Gecko/Netscape)'; } else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') ) { $browser = 'Mozilla Firefox (Gecko/Firefox)'; } else { $browser = 'Mozilla (Gecko/Mozilla)'; } } else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) { if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') ) { $browser = 'Opera (MSIE/Opera/Compatible)'; } else { $browser = 'Internet Explorer (MSIE/Compatible)'; } } else { $browser = 'Others browsers'; } if ($_SERVER['HTTP_X_FORWARD_FOR']) { $ip = $_SERVER['HTTP_X_FORWARD_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); echo "Hello Visitor, here is your Info:<br><br>"; echo "You are using: " . $browser . "<br>"; echo "Your IP is: " . $ip . "<br>"; echo "Your Hostname is: " . $hostname; ?> PHP:
Thank you very much mehdi I added you a reputation. Also I am looking for a free script with no link back which shows a beautiful Country flag of the visitors Also if there's any script to find the User's ISP details. It would be great if you help me again in these matters
Have a look: http://www.boastology.com/tools/ip2c.php they are not providing the script, but give you a code to insert in your webpage.
I would use the following for IP, it tends to work better. <? $ip = (getenv(HTTP_X_FORWARDED_FOR)) ? getenv(HTTP_X_FORWARDED_FOR):getenv(REMOTE_ADDR); echo $ip; ?> PHP:
Hey mehdi you are the man, this is what I have been looking for. I am very grateful to you, your a very useful person Thank you so so so much with all my heart with all my spirit God Bless.