[TriLUG] Restricting access within PHP

Timothy A. Chagnon tchagnon at futeki.net
Fri Jun 24 19:43:18 EDT 2005


I would add a little bit since there are some browsers (you know which)
that do not handle the location header redirect correctly and might
display the rest of your page.  It's old-skool ghetto, but the
meta-refresh is the most reliable way to redirect people.  It's the
exit() that's important though, to make sure the people don't see the
rest of the page.

On Fri, 2005-06-24 at 13:48, Tobias Crawley wrote:
> if ( strpos( $_SERVER[ 'REMOTE_ADDR' ], '192.168.1.' ) === false ) {
>   //redirect to another page
>   header( 'location: otherpage.php' );

    print '<html><head>';
    print '<meta http-equiv="REFRESH" content="0; URL=http://foo.bar/otherpage.php">';
    print '<body>Denied</body></html>';

    exit();
> }

-- 
Timothy A. Chagnon
Linux, how do I love thee?
Let me count the ways:
while(1){count++;}




More information about the TriLUG mailing list