Page 1 of 1

Session variable index error

Posted: Wed Sep 27, 2006 1:41 pm
by fitchic77
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


url would be
/localhost.com/index.php?action=TEST1

//index.php

Code: Select all

session_start();
if ($action  == "TEST1") { 
include("test1.php");						
} elseif ($action  == "TEST2") {  //edit user sales
include("test2.php");
}

//form test1.php
$_SESSION['logged'] = "logged";
echo $_SESSION['logged'] ;

//form test2.php
echo "here" . $_SESSION['logged'];

Code: Select all

RECEIVE error and my session is not defined
Notice: Undefined index: logged in C:\Program Files\Apache2\htdocs\test\test2.php on line 3



feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Sep 27, 2006 1:47 pm
by SpecialK
in index.php $action isn't set.

test2.php doesn't set
$_SESSION['loggedTest'] = "Test";

while test1.php does set it.

Using isset() is the way to check this without getting any warning errors prior to using the index of loggedAndrea

Posted: Wed Sep 27, 2006 1:52 pm
by fitchic77
Sorry I was cutting and pasting the code and left this out. The issue is the session variable not setting right.

Code: Select all

$action = $_REQUEST['action']

thanks.

Posted: Wed Sep 27, 2006 1:54 pm
by volka
is there a session_start() in test2.php, too?

Posted: Wed Sep 27, 2006 2:00 pm
by fitchic77
doesn't have to be because everything is ran through index.php which has it...

I have it working now...not sure what the hangup was...

thanks.