Reputation: 1
This is my index page
session_start();
if(!isset($_SESSION["manager"])){
header("location:admin_login.php");
exit();
}
#Be sure to chack that this manager SESSION value is in fact in the database
$managerID =preg_replace('#[0.9]#l','',$_SESSION['id']);//filter everything but numbers and letters
$manager = preg_replace('#[A_Za_z0.9]#i','',$_SESSION["manager"]);//filter everything but numbers and letters
$password = preg_replace('#[A_Za_z0.9]#i','',$_SESSION["password"]);//filter everything but numbers and letters
//Run mySQL query to be sure that this person is an admin and that thier password session var equals the database informartion
//Connect to MYSQL database
include "../storescripts/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM `admin` WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1");//query the person
//........MAKE SURE PERSONE EXISTS IN DATABASE....
$existCount = mysql_num_rows($sql);//Count the row nums
if($existCount == 0){//evaluate the count
header("location:../index.php");
exit();
}
This is my admin_login page
session_start();
if(!isset($_SESSION["manager"])){
header("location:index.php");
exit();
}
?>
<?php
#Palse the log in from if user has filled it out and pressed "Log In"
if(isset($_POST["username"])&&isset($_POST["password"])){
$manager = preg_replace('#[A_Za_z0.9]#i','',$_POST["username"]);//filter everything but numbers and letters
$password = preg_replace('#[A_Za_z0.9]#i','',$_POST["password"]);//filter everything but numbers and letters
//connect to the MYSQL database
include "../storescripts/connect_to_mysql.php";
$sql = mysql_query("SELECT id FROM `admin` WHERE username='$manager' AND password='$password' LIMIT 1");//query the person
//........MAKE SURE THE PERSONE EXISTS IN DATABASE....
$existCount = mysql_num_rows($sql);//Count the row nums
if($existCount==1){//evaluate the count
while($row=mysql_fetch_array($sql)){
$id=$row['id'];
}
$_SESSION["id"]=$id;
$_SESSION["manager"]=$manager;
$_SESSION["password"]=$password;
header("location:index.php");
exit();
} else {
echo "That information is incorrect,try again<a href='index.php'>Click Here</a>";
exit();
}
}
i have error on google chrome :
Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
Upvotes: 0
Views: 1550
Reputation: 989
try to var_dump($_SESSION);
, it's either not set properly or session is not started
Upvotes: 0
Reputation: 4293
In both index page and admin_login page, there is $_SESSION["manager"] check and hence if the manager index is not set, there is a redirection loop between these two URLs.
You may want to remove the Session check in admin_login page.
Upvotes: 1