Posted By

scopefragger on 08/31/09


Tagged

redirect browser user


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

umang_nine
scopefragger


Redirecting your users browser


 / Published in: PHP
 

URL: http://www.scopesden.co.uk/code_get_feed.php?Content_ref=5

Sometimes you just need to mask a script or reject a user from a page this can be done effortlessly using a single line of code. Header location will allow you to redirect a user quickly and without them having any control over the action.

A good example of this forced redirection is an “if” statement. Here is a simple if statement using the header location. If the users ip addres = ’192.167.3.2’ then they will be redirected to the wanted page, else they will be rejected and taken to another page such as a 401 or 403

if ($ipaddress==’192.167.3.2’){ header('Location: http://www.example.com/allowin.php'); } else { header('Location: http://www.example.com/ deny_acces.php '); }

  1. header('Location: http://www.example.com/allow_in.php');

Report this snippet  

You need to login to post a comment.