Saturday, October 8, 2016

How to Find out Visitor's IP Address

Here is how to find out a visitor's IP address using PHP:
<?php
    echo $_SERVER['REMOTE_ADDR']
?>

You can always embed this in HTML file:
<html>
<head></head>
<body>
    Your IP Address is <?php echo $_SERVER['REMOTE_ADDR'] ?>.
</body>
</html>

Note that the web server must be configured to parse the PHP code inside html file to display it correctly. You may want to refer tho this post to do this in Debian.

No comments:

Post a Comment