View Single Post
  #2 (permalink)  
Old July 3rd, 2004, 05:18 PM
richard.york's Avatar
richard.york richard.york is offline
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts

The problem is with this line:

if ($_SESSION['authuser']!=1)

PHP is complaining because you have used a variable before it has been created. There are a couple of ways around this.

The first is to flip your authentication in the script itself so that the script first checks for an authenticated user.

if (isset($_SESSION['authuser']) && $_SESSION['authuser'] == 1) {

    // Do member's only content here

} else {

    // The variable doesn't exist or does not contain a value of 1.


This works because I've used a special language construct called isset(), which checks for a variable's existence, because it checks for a variable's existence it doesn't throw the NOTICE level error.

"Undefined index" refers to the index of an associative array, as in $_SESSION['authuser'] $_SESSION is the array and 'authuser' is the indice.

From what I've seen on the forum the authors reserved discussion about these types of errors for its own chapter.. since discussion of errors, error supression and troubleshooting would have bloated the content of the book.

Let us know if you have any more questions.


The Spicy Peanut Project