Get Dynamic And Static IP Address Of Visitor In PHP
Suppose we have a website and we want to get the user IP address and want to display it for him or we want to store it and get a log for the hits of website. Also sometimes users may share same IP address for internet sharing & usage so his PC’s IP will be something like 192.168.0.2 (Proxy Case) and actual IP address which he is using for internet, shared by his internet service provider will be different. We can find these both IP by this simple example of PHP code.
Use the following code.
<?php $domain=$_SERVER['REMOTE_ADDR']; $domain1 = isset($_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; echo "Viewer's Server's IP Address: <strong>$domain</strong> - "; echo "Viewer's PC IP Address: <strong>$domain1</strong>"; ?>
For more PHP scripts: Visit [ PHP Magic Book ]