admin login php code


#1

hey guys i have a problem with my admin login php. when i open the page, i get redirected to the admin login message that i have sent up and i am unable to get to the login page. i have two page, the first in the index.php which i am trying to access and the second is the admin_login.php page that should allow me to sign in.

i have a very funny feeling that it is something stupid that i am missing ( like a ; or bracket) so if someone could help me find the mistake i would be very grateful

here is the index.php
code[php]<?php
session_start();
if(!isset($_SESSION[“manager”])){
header(“location: admin_login.php”);
exit();
}

$managerID = preg_replace(’#[^0-9]#i’,’’, $_SESSION[“id”]);
$manager = preg_replace(’#[^A-Za-z0-9]#i’,’’, $_SESSION[“manager”]);
$password = preg_replace(’#[^A-Za-z0-9]#i’,’’,$_SESSION[“password”]);
include"http://http://localhost/test/connect_to_mysql.php";

$sql=mysql_query(“SELECT*FROM employee WHERE EmID =’$managerID’ and username = ‘$manager’ and password = ‘$password’ LIMIT 1”);

$existCount = mysql_num_rows($sql);
if ($existCount == 0){
echo “Your login session data is not in right”;
exit();
}
?>

admin area
<?php include_once("../pageheader.php")?>

Manage Animal Entries

Manage Employees

<?php include_once("../pagefooter.php")?>
[/php]

and here is the admin_login.php code
[php]<?php
session_start();
if(isset($_SESSION[“manager”])){
header(“location: admin_login.php”);
exit();
}
?>

<?php //parse log in form 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 letters and numbers $password=preg_replace('#[^A-Za-z0-9]#i', '' ,$_POST["password"]); //filter everything but letters and numbers include "localhost/test/admin/connect_to_mysql.php"; $sql = mysql_query("SELECT EmID FROM admin WHERE username='$manager' AND password='$password' LIMIT 1"); $existCount=mysql_num_rows($sql); if($existCount==1){ while($row=mysql_fetch_array($sql)){ $id=$row["id"]; } $_SESSION["id"]=$id; $_SESSION["manager"]=$manager; $_SESSION["password"]=$password; } }else{ echo 'The provided information is incorrect, try again Click Here'; exit(); } ?> admin area
<?php include_once("http://localhost/test/pageheader.php")?>
username:


password:



[/php]

Thanks in advance


#2

session_start();
if(!isset($_SESSION[“manager”])){
header(“location: admin_login.php”);
exit();
}

IF session manager is set it will send you to the admin login.

So once you first visited your page it shows you index.php
You goto log in and it takes you to admin_login.php from a menu link I’m guessing.
When you login there. It sets the manager session which takes you back to admin login when ever you go to index.php
Is that the issue your having?