Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pepeleuepe

macrumors 6502
Original poster
Oct 27, 2002
252
0
Los Angeles, California
First off, the problem I am trying to solve:

1. I have a page on my site that I want to be loosely secure, basically a user can't just click through to get to the page. I don't want it to be bulletproof by any means and I don't even care if it is linkable or bookmarkable, just some kind of quasi-security to stop prying, computer illiterate eyes from seeing the page.

2. I also have a phpbb database of users already registered.

Solution:

Make a script to access the phpbb database logins and passwords and determine if the user will be passed on to the page, or rejected.

Well, I have everything working fine except for the very very last and seemingly simple part. Once the script determines that the user is authorized, how do I redirect the user to the next page? I'm new to PHP, but not to programming, and have found everything else I need in books or on php.net, but I can't seem to stumble across a means of implementing this. I'm sure its one simple line of code, but I can't seem to find it, so if you can help, please do.
 

colocolo

macrumors 6502
Jan 17, 2002
480
132
Santiago, Chile
The simplest way, and what I do most of the time, is to just close php and redirecto throgh javascript; it will address just fine your problem.
something like:

if (authorized)
{
?>
<script>
location.href="otherpage.php"
</script>
<?
}
else
echo("Access denied");
?>
 

Singen

macrumors newbie
Jan 27, 2004
2
0
Hellsinki
And by using PHP

Also, you can use PHP to send http headers. So, within PHP just:

PHP:
<?php

if($authenticated) {
  header("Location: http://www.example.com/secret_dir/");
} else {
  header("Location: http://www.example.com/notloggedin.html");
}

?>

By using this the client browser doesn't need to have javascript support.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.