Jump to content

[SOLVED] $_SESSION PROBLEM


plodos

Recommended Posts

if I login the system as a reviewer, login_control.php must open the reviewer.php page

 

id  username  password    email        type

1        p                p            a@a      reviewer

 

login_control.php

<?php $sql="SELECT * FROM user WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);
    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    // If result matched table row must be 1 row
    if($count==1){
    	$row	= mysql_fetch_array($result);
	$_SESSION['loggedIn'] = $row['type'];
	$_SESSION['id']		  = $row['id'];
	header("location:{$row['type']}.php?");
} ?>

 

but problem starts here. My username and password is true, and type is reviewer.

when I try to login the system as a reviewer, header("location:index.php"); is open the index page. WHY ?

reviewer.php

<?php 
include('dbconfig.php');

session_start();

if ($_SESSION['loggedIn'] != 'reviewer')
{   //check the registered user, if not go index.php 
if(!$_SESSION['id'])
{
	header("location:index.php"); 
	die();
}
else //if registered with different user type turn back to your page
{
  echo " <script language='JavaScript'>history.go(-1);</script>";  
}
}
else
{ 
    //open the secure page 
}
?>

Link to comment
https://forums.phpfreaks.com/topic/138327-solved-_session-problem/
Share on other sites

there are the errors when I try to login as a reviewer with reviewer information

 

Notice: Undefined index: loggedIn in /home/bbp/reviewer.php on line 6

 

Notice: Undefined index: id in /home/bbp/reviewer.php on line 8

 

Notice: Undefined index: id in /home/bbp/reviewer.php on line 12

 

Notice: Undefined index: loggedIn in /home/bbp/reviewer.php on line 13

if($count==1){
    	$row	= mysql_fetch_array($result);
	$_SESSION['loggedIn'] = $row['type'];
	$_SESSION['id']		  = $row['id'];
	header("location:{$row['type']}.php?id={$row['id']}&type={$row['type']}");
}

http://aaaa.com/reviewer.php?id=9&type=reviewer

ID is true, TYPE is true

 

BUT why this part is working FALSE, WHY header("location:index.php"); is working ???? Please help me

<?php 
include('dbconfig.php');
session_start();

if ($_SESSION['loggedIn'] != 'reviewer')
{   //check the registered user, if not go index.php 
if(!$_SESSION['id'])
{
	header("location:index.php"); 
	die();
	//echo $_SESSION['id'];
	//echo "<br>".$_SESSION['loggedIn'];
}
else //if registered with different user type turn back to your page
{
  echo " <script language='JavaScript'>history.go(-1);</script>";  
}
}else{ //page starts here
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.