Jump to content

Sessions Problem


dubt2nv

Recommended Posts

i basically have a log-in page where a user can log in to get into a maintenance area that isnt permitted to the public....when i log in it goes through a

process login script php file;

[code]<?php
session_start();
header("Cache-control: no-cache");


//this includes the database connection
include("database.inc");


//Get the user's input from the form

$username = trim($_POST['user']);


//Get the user's input from the form

$password = trim($_POST['pass']);



//check username and password are correct
$users_query = "SELECT * FROM user where username = '$user' AND password = '$pass'";
//echo $users_query;
$mysql_result=mysql_query($users_query,$conn);

$row=mysql_fetch_row($mysql_result);



//if valid user doesnt exist set the error message and redirect to badlogin page
if ($row[0]=="")
{
//echo "nooo";
header("Location: http://kieren.classroomonline.info/Kieren%20Lollback/error.htm");
}
else
{
//if valid user exists set all the session variables
//$row is the record, [3] is the 3rd element(field) in the array

$_SESSION['Level']=$row[1];

//redirect to the page you want to allow the user to access
//echo "yesss";
header("Location: http://kieren.classroomonline.info/Kieren%20Lollback/index.htm");

}
?>

[/code]



but then when i get to the page after log-in it seems as though the page isnt secured...even though i have a security.inc file;

[code]<?php
session_start();
if ($Level == "Admin") {
header("Location: http://kieren.classroomonline.info/Kieren%20Lollback/index.htm");
}
else
if ($Level == "Owner") {
  header("Location: http://kieren.classroomonline.info/Kieren%20Lollback/awareness2.htm");
}
?>[/code]


WHERE AM I GOING WRONG..... and each page has the security include title at the start...

[code]<?php include("security.inc");?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/28623-sessions-problem/
Share on other sites

[code]//$row is the record, [3] is the 3rd element(field) in the array

$_SESSION['Level']=$row[1];[/code]

Should the [1] be [3], or have you changed the code and not the comment?

Thorpe is referring to your security.inc file, but I think the answer he is looking for is the bit of code in my post.
Link to comment
https://forums.phpfreaks.com/topic/28623-sessions-problem/#findComment-131583
Share on other sites

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.