View Full Version : Simple PHP question

Jan 27, 2004, 12:31 AM
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.


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.

Jan 27, 2004, 12:57 AM
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)
echo("Access denied");

Jan 27, 2004, 03:32 AM
Also, you can use PHP to send http headers. So, within PHP just:


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.