I was attempting to follow along with the tutorial at the YouTube channel Helping Develop
when I came across a few issues. The first being his logout code in tutorial #5 doesn't work anymore due to the changed
if(session_is_registered()
I think I have replaced that properly with
if( isset($_SESSION[$username])){
But now I am getting an error that says
"Notice: Undefined variable: logged in C:\xampp\htdocs\membership\index.php on line 2"
When I check line 2 of index it shows that i am including global.php first
<?php include_once('scripts/global.php');
if($logged==1){
header("Location:home.php");
exit();
}
?>
So then I check global.php which has $logged=1 so it should be defined...unless I am missing something. I am really trying to learn more here, so any help would be appreciated in explaining what is wrong, and why.... Thank you.
<?php
session_start();
include_once('scripts/connect.php');
//checking if the sessions are set
if(isset($_SESSION['username'])){
$session_username=$_SESSION['username'];
$session_pass=$_SESSION['pass'];
$session_id=$_SESSION['id'];
//checking the member data
$query=mysql_query("SELECT * FROM members WHERE
id='id' AND password='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();
}
}elseif(isset($_COOKIE['id_cookie'])){
$session_id=$_COOKIE['id_cookie'];
$session_pass=$_COOKIE['pass_cookie'];
//checking the member data
$query=mysql_query("SELECT * FROM members 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();
}
}
?>