DanielTech
07-31-2004, 04:05 PM
I am getting "Undefined index" error every time I use $_SESSSION['password'] in a Login application. It looks like my $_SESSSION['password'] is not defined or something similar. Any idea?
Here is my code:
//Login.php
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<FORM METHOD="POST" ACTION="members.php">
Enter your Name: <input type="text" name="name">
<br>Enter password: <input type="password" name="password"><br>
<input type="SUBMIT" value="Submit">
</FORM>
</body>
</html>
//members.php
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<html>
<head>
<title>Members</title>
</head>
<body>
<?
echo "<strong>Members page</strong><br />";
// Get the user's input from the form
$name = $_POST['name'];
// Register session key with the value
$_SESSION['name'] = $name;
$_SESSSION['password'] = $_POST['password'];
// Display the sssion information:
?>
Welcome to my website <strong><? echo $_SESSION['name']; ?></strong>!<br/>
<?
if($_SESSION['password']=='')
{
echo 'yes';
}
else
{
echo 'no';
}
?>
Your pass is: <? echo $_SESSION['password']; ?><br><br>
Let's see what happens on the <a href='logout.php'>next page.</a><br/><br/>
</body>
</html>
thanks,
DanielTech
Here is my code:
//Login.php
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<FORM METHOD="POST" ACTION="members.php">
Enter your Name: <input type="text" name="name">
<br>Enter password: <input type="password" name="password"><br>
<input type="SUBMIT" value="Submit">
</FORM>
</body>
</html>
//members.php
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<html>
<head>
<title>Members</title>
</head>
<body>
<?
echo "<strong>Members page</strong><br />";
// Get the user's input from the form
$name = $_POST['name'];
// Register session key with the value
$_SESSION['name'] = $name;
$_SESSSION['password'] = $_POST['password'];
// Display the sssion information:
?>
Welcome to my website <strong><? echo $_SESSION['name']; ?></strong>!<br/>
<?
if($_SESSION['password']=='')
{
echo 'yes';
}
else
{
echo 'no';
}
?>
Your pass is: <? echo $_SESSION['password']; ?><br><br>
Let's see what happens on the <a href='logout.php'>next page.</a><br/><br/>
</body>
</html>
thanks,
DanielTech