PAGE1 User enters his name, clicks submit button.
PAGE2 I display his name and a hyperlink to move to 3rd page.
PAGE3 Here I can no longer display his name from the $_SESSION['name'] variable.
I've looked around at other posts and I dont see anything I'm doing wrong.
Note: Page2 DOES work. It's page3 that doesn't show his name.
Here's my code. (I have <? session_start(); ?> at the top of all my pages!)
PAGE1
Simple text box and submit button. Nothing special
Page2
<?php
session_start();
$name = $_POST['name'];
$_SESSION['name'] = $name;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Main Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
echo $_SESSION['name'].", Welcome to my website!";
?>
<a href="main2.php">Click here to continue</a>
</body>
</html>
PAGE 3
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
if (empty($_SESSION['name']))
{
echo "You have not logged in...<BR>";
exit;
}
else
{
echo "Welcome ".$_SESSION['name']."<BR>";
echo "<a href = \"delete.php\">Lets delete the session value</a><br>";
echo "<a href = \"destroy.php\">Lets destroy the session</a><br>";
}
?>
</body>
</html>
When I try and view PAGE3, I get the "You have not logged in..." message. Again, PAGE2 works, not PAGE3