View Single Post
  #1 (permalink)  
Old July 3rd, 2004, 09:37 AM
Airidh Airidh is offline
Authorized User
 
Join Date: Jul 2004
Location: Isle of South Uist, Outer Hebrides, United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 2 Page 53: Undefined index: authuser

Help! I am running under Windows 98,and PHP and Apache are installed on the E: partition of my first disk. When clicking on the link in movie1.php I get the following message:

Notice: Undefined index: authuser in e:\apache\apache\test\moviesite.php on line 4
Sorry, but you don't have permission to view this page

I have read all the posts that seemed relevant in the forum, including those pointed to by Richard York, but I still can't make it work. I've probably made a stupid mistake, but can't see it. Up to Page 51 everything has worked fine.

----------------------------------------------------------------------

Here's the code:

(movie1.php)
<?php
session_start();
$_SESSION['username']="Joe12345";
$_SESSION['authuser']=1;
?>
<HTML>
<HEAD>
<TITLE>Find my favourite 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 favourite movie!";
    echo "</a>"
?>
</BODY>
</HTML>

(moviesite.php)
<?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";
        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>

----------------------------------------------------------------------

So I commented out lines 4 - 8 of moviesite.php, and the message became:

Welcome to our site
Notice: Undefined index: username in e:\apache\apache\test\moviesite.php on line 17
!
My favourite movie is Life of Brian
My movie rating for this movie is: 5

----------------------------------------------------------------------

Here is a selection of directives from C:\windows\php.ini:

output_buffering=Off
error_reporting= E_ALL; display all errors, warnings and notices
display_errors=On
display_startup_errors=Off
log_errors=On
error_log=E:\PHP\err.log
mysql.allow_persistent=On
session.save_handler=files
session.save_path=E:\PHP\tmp
session.use_cookies=1

----------------------------------------------------------------------
The folder E:\PHP\tmp does exist (I created it) but contains nothing. It looks as if the variables are never stored by movie1.php, but I can't see what's wrong.

Any help will be appreciated! Thanks

Edna



Reply With Quote