Passing through sessions
Hi,
I am working on chapter 2 of beginning php,mysql and apache - moviesite.php and movie1.php. I am now working on Passing variables through sessions. I have cut and past the code (which I downloaded from the wrox site) for both php files (therefore if the code is coming from the source, it surely must be ok).
Every time I click the hyperlink: "click here to see information...." on the movie1.php, it should return:
Welcome to our site Joe 12345
My favourite movie is Life of Brian
My movie rating for this movie is : 5
However (even when I use the code from the book) No session information is passed at all, and all I get is:
My favorite movie is Life of Brian
My movie rating for this movie is: 5
Here is the code I'm using from the book:
movie1.php:
<?php
session_start();
$_SESSION['username']="Joe12345";
$_SESSION['authuser']=1;
?>
<HTML>
<HEAD>
<TITLE>Find my Favorite Movie!</TITLE>
</HEAD>
<BODY>
<?php
$myfavmovie=urlencode("Life of Brian");
echo "<a href='http://localhost/moviesite.php?favmovie=$myfavmovie'>";
echo "Click here to see information about my favorite movie!";
echo "</a>";
?>
</BODY>
</HTML>
moviesite.php code:
<?php
session_start();
//check to see if user has logged in with a valid password
if ($_SESSION['authuser']!=1) {
echo "Sorry, but you don't have permission to view this page, you loser!";
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 favorite movie is ";
echo $_REQUEST['favmovie'];
echo "<br>";
$movierate=5;
echo "My movie rating for this movie is: ";
echo $movierate;
?>
</BODY>
</HTML>
I have checked the registered globals are off (they are) and made sure the php.ini file "session_save_path" is pointing to the C:/temp (which it is).
Does anybody no whats wrong or what I am doing wrong? I basically can't progress through the book until I resolve the problem as the next section uses sessions and cookies, and It won't work if the sessions don't work.
Help!!!!!
Kind regards
David
|