alright so I have muliple different files and I think I know where my error is. I want to have my page set so that when a client logs in they they set the logged variable to 1 and not 0. So far whenever I log in the variable is staying at 0 there must be an issue.
here is the global.php file
<?php include_once("connect.php"); session_start(); if(isset($_SESSION['username'])) { header("Location: index.php"); //checking if sessions are set. if(isset($_SESSION['username'])){ $session_username = $_SESSION['username']; $session_pass = $_SESSION['pass']; $session_id = $_SESSION['id']; //check if the member exists $query = mysql_query("SELECT * FROM clients WHERE id='$session_id' AND password='$session_pass'LIMIT 1") or die("Could not check member"); $count_count = mysql_num_rows($query); if($count_count > 0){ //logged in stuff here $logged = 1; }else{ header("Location: logout.php"); exit(); } }else if(isset($_COOKIE['id_cookie'])){ $session_id = $_COOKIE['id_cookie']; $sessions_pass = $_COOKIE['pass_cookie']; //check if the member exists $query = mysql_query("SELECT * FROM clients WHERE id='$session_id' AND password='$session_pass'LIMIT 1") or die("Could not check member"); $count_count = mysql_num_rows($query); if($count_count > 0){ while($row= mysql_fetch_array($query)){ $session_username = $row['username']; } //create sessions $_SESSION['username']=$session_username; $_SESSION['id']=$session_id; $_SESSION['pass']=$session_pass; //logged in stuff here $logged = 1; }else{ header("Location: logout.php"); exit(); } }else{ //if the user is not logged in $logged = 0; } } ?>
here is the login.php script
<?php include_once("scripts/global.php"); if(isset($_POST['email'])){ $email = $_POST['email']; $pass = $_POST['pass']; $remember = $_POST['remember']; //error handeling if((!$email)||(!$pass)){ $message = 'Please insert both fields'; }else{ // secure the data $email = mysql_real_escape_string($email); $pass = sha1($pass); $query = mysql_query("SELECT * FROM clients WHERE email='$email' AND password='$pass' LIMIT 1" ) or die("Could not check member"); $count_query = mysql_num_rows($query); if($count_query == 0){ $message = 'The information you entered is incorrect'; }else{ //start session $_SESSION['pass'] = $pass; while($row = mysql_fetch_array($query)){ $username = $_row['username']; $id = $row['id']; } $_SESSION['username'] = $username; $_SESSION['id'] = $id; if($remember == "yes"){ //create cookies setcookie("id_cookie",$id,time()+60*60*24*100,"/"); setcookie("pass_cookie",$pass,time()+60*60*24*100,"/"); } header("Location: home.php"); } } } ?>