BLOG

PHP Sheet

27 Apr 2011, Posted by BoB in All Posts, Website Talk

How to display a user’s IP address within a web page:

<?php echo $_SERVER[‘REMOTE_ADDR’]; ?>
(Paste above code in your PHP file)

How to display information only to an IP address of your choosing:

Find your IP address at ip.TRPunlimited.com
<?php if ($_SERVER[‘REMOTE_ADDR’] == your.ip.address.here) {?>
(Paste above code at the beginning of the protected information)

<?php } ?>
(Paste above code at the end of the protected information)

How to automatically redirect to another web page:

<?php
header(“refresh: 5; http://www.example.com/example.html”);
?>
(Paste above code in your PHP file)
*Note* Where you currently see a “5” you can change to how ever long you would like to wait for the page to redirect (in seconds)

Post a comment