Hello,
Can somebody help me with this script?
I have a registration form that provides an option for three different program types:
BMUS, MASTERS, and DMA. What I would like to do is use an existing (fully functional) login script that points a user to their respective 'private' area:
For example:
BMUS = private1.php
MASTERS = private2.php
DMA = private3.php
At the top of each of these pages there is a "require_once" script that points to this authorzation.php script:
<?php
//Start session
session_start();
//Check whether the session variable
//SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID'])=='') ) {
header("location: denied.php");
exit();
}
?>
So.. After the user has successfully registered, and then logged in, they will go to one of the private pages.
The problem:
BMUS students (users) can see MASTERS, or DMA pages (private2.php and private3.php) when they should only be able to see the BMUS page (private1.php)
This is the login script that is used after a successful registration:
<?php
$qry="SELECT member_id, location FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result)>0) {
//Login Successful
session_regenerate_id();
$member=mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID']=$member['member_id'];
session_write_close();
switch ($member['location'])
{
case "private1.php":
header("location: private1.php");
$_SESSION['page_allowed']="private1.php";
break;
case "private2.php":
header("location: private2.php");
$_SESSION['page_allowed']="private2.php";
break;
case "private3.php":
header("location: private3.php");
$_SESSION['page_allowed']="private3.php";
break;
default:
header("location: failed.php");
break;
}
//end new code
exit();
}else {
//Login failed
header("location: failed.php");
exit();
}
}else {
die("Query failed");
}
?>
Please note the $_SESSION['page_allowed']="private1.php"; part of the case structure.
How can I add the "page_allowed" function to each of the private pages so only their respective page can be accessed? I think there needs to be a concatenated string added to the authorization.php script but I'm not sure.
I hope that's clear! Thank you kindly for your time.
W