Hello.
I am just beginning to teach myself the basics of php. I am learning from books and video tutorials etc. I have come across a problem that I just can't work out, I'm sure it is very simple.
Two files, movie1.php and moviesite.php, movie1.php looks like this:
<?php
session_start();
$_SESSION['username'] = "Joe12345";
$_SESSION['authuser'] = 1;
?>
<html>
<head>
<title>Find My Movie!</title>
</head>
<body>
<?php
$myfavmovie = urlencode("The Life of Brian");
echo "<a href='moviesite.php?favmovie=$myfavmovie'>";
echo "click here to see information about my favourite movie!";
echo "</a>"
?>
</body>
</html>
OK? You see the '$_SESSION['username'] = "Joe12345";', this is my specific problem. This should be echoed into the next page, moviesite.php which you can see below:
<?php
session_start();
//check to see if the user has logged in with a valid password
if ($_SESSION['authuser'] != 0) {
echo "sorry, but you don't have permission to view this page";
exit();
}
?>
<html>
<head>
<title>My Movie Site - <?php echo $_REQUEST['favmovie']; ?></title>
</head>
<body>
<?php
echo "Welcome to our site, ";
echo $_SESSION['username'];
echo "! <br>";
echo "My favourite movie is ";
echo $_REQUEST['favmovie'];
echo "<br>";
$movierate = 5;
echo "My movie rating for this movie is ";
echo $movierate;
?>
</body>
</html>
OK? 'echo $_SESSION['username'];' does not echo the username. Everything else seems to be ok.
This is an example I have been working on from the book 'Beginning PHP, MySQL and Apache Web Development'.
I hope someone can help. The username 'Joe12345' is not carried to the next page. It is just blank.
Many Thanks for all and any assistance people can give me.