Session Problem
Moderator: General Moderators
Session Problem
I am having a problem with sessions:
I am using Apache, PHP, APACHE on Windows XP pro.
I have a login page that creates a session. After loggin in a wanted to display the session.
Funny thing is that in Netscape it works fine but in IE6 I get this error:
Notice: Undefined index: Username in C:\Apache\Apache Group\Apache2\htdocs\userareas\home.php on line 120
HELP!?
Thanks
Jeff
I am using Apache, PHP, APACHE on Windows XP pro.
I have a login page that creates a session. After loggin in a wanted to display the session.
Funny thing is that in Netscape it works fine but in IE6 I get this error:
Notice: Undefined index: Username in C:\Apache\Apache Group\Apache2\htdocs\userareas\home.php on line 120
HELP!?
Thanks
Jeff
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
Ok yes they were different. One was username and the other was Username. I changed it to lower case.
Getting the error: Notice: Undefined index: username in C:\Apache\Apache Group\Apache2\htdocs\userareas\home.php on line 120
This is from the login page:
} else {
mysql_free_result($rsLogin);
session_register("username");
$HTTP_SESSION_VARS['username'] = $HTTP_POST_VARS['username'];
header("Location: userareas/home.php");
}
On the next page I am displaying the session var with:
<?php echo $_SESSION['username']; ?>
Which is line 120.
Getting the error: Notice: Undefined index: username in C:\Apache\Apache Group\Apache2\htdocs\userareas\home.php on line 120
This is from the login page:
} else {
mysql_free_result($rsLogin);
session_register("username");
$HTTP_SESSION_VARS['username'] = $HTTP_POST_VARS['username'];
header("Location: userareas/home.php");
}
On the next page I am displaying the session var with:
<?php echo $_SESSION['username']; ?>
Which is line 120.
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
I changed my login page:
mysql_free_result($rsLogin);
$_SESSION['username'] = $_POST['username'];
header("Location: userareas/home.php");
It still works in netscape but not IE6. Get error:
Notice: Undefined index: username in C:\Apache\Apache Group\Apache2\htdocs\userareas\home.php on line 117
Weird
mysql_free_result($rsLogin);
$_SESSION['username'] = $_POST['username'];
header("Location: userareas/home.php");
It still works in netscape but not IE6. Get error:
Notice: Undefined index: username in C:\Apache\Apache Group\Apache2\htdocs\userareas\home.php on line 117
Weird
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
There is a error on the login page. Sorry I didn't see it because I have a form on a different page and it just goes to the login page to validate. The error is:
Notice: Undefined variable: errorMessage in C:\Apache\Apache Group\Apache2\htdocs\login.php on line 55
Code:
<?php
session_start();
?>
<?php require_once('Connections/connUserareas.php'); ?>
<?php
$myUsername_rsLogin = "0";
if (isset($HTTP_POST_VARS['username'])) {
$myUsername_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['username'] : addslashes($HTTP_POST_VARS['username']);
}
$myPassword_rsLogin = "0";
if (isset($HTTP_POST_VARS['password'])) {
$myPassword_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['password'] : addslashes($HTTP_POST_VARS['password']);
}
mysql_select_db($database_connUserareas, $connUserareas);
$query_rsLogin = sprintf("SELECT Username, Password FROM companies WHERE Username = '%s' AND Password = '%s'", $myUsername_rsLogin,$myPassword_rsLogin);
$rsLogin = mysql_query($query_rsLogin, $connUserareas) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);
if($HTTP_POST_VARS['action']=="login"){
if($totalRows_rsLogin==0){
$errorMessage = "Your Login Information is incorrect";
mysql_free_result($rsLogin);
} else {
mysql_free_result($rsLogin);
$_SESSION['username'] = $_POST['username'];
echo "<script language=javascript>location.replace('userareas/home.php')</script>";
}
}
error_reporting(E_ALL);
ini_set('display_errors', true);
?>
Notice: Undefined variable: errorMessage in C:\Apache\Apache Group\Apache2\htdocs\login.php on line 55
Code:
<?php
session_start();
?>
<?php require_once('Connections/connUserareas.php'); ?>
<?php
$myUsername_rsLogin = "0";
if (isset($HTTP_POST_VARS['username'])) {
$myUsername_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['username'] : addslashes($HTTP_POST_VARS['username']);
}
$myPassword_rsLogin = "0";
if (isset($HTTP_POST_VARS['password'])) {
$myPassword_rsLogin = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['password'] : addslashes($HTTP_POST_VARS['password']);
}
mysql_select_db($database_connUserareas, $connUserareas);
$query_rsLogin = sprintf("SELECT Username, Password FROM companies WHERE Username = '%s' AND Password = '%s'", $myUsername_rsLogin,$myPassword_rsLogin);
$rsLogin = mysql_query($query_rsLogin, $connUserareas) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);
if($HTTP_POST_VARS['action']=="login"){
if($totalRows_rsLogin==0){
$errorMessage = "Your Login Information is incorrect";
mysql_free_result($rsLogin);
} else {
mysql_free_result($rsLogin);
$_SESSION['username'] = $_POST['username'];
echo "<script language=javascript>location.replace('userareas/home.php')</script>";
}
}
error_reporting(E_ALL);
ini_set('display_errors', true);
?>
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
again, change $HTTP_POST_VARS to $_POST
the current error is from $errorMessage not being set because the outermost if statement it is in will never be true becasue $HTTP_POST_VARS['action'] is not set
also - you open and close php tages three times with nothing in between. Is that because you're cutting and pasting onto here?
the current error is from $errorMessage not being set because the outermost if statement it is in will never be true becasue $HTTP_POST_VARS['action'] is not set
also - you open and close php tages three times with nothing in between. Is that because you're cutting and pasting onto here?
Last edited by magicrobotmonkey on Mon Apr 05, 2004 11:23 am, edited 1 time in total.
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA