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
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

Link to comment
Share on other sites

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
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.