Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2006, 12:54 PM
Registered User
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP Session error

Hi there. I'm very new to PHP and it's amazing world and I've been working through the Beginning PHP, Apache, MySQL Web Development book and it wasn't before long that I encountered a problem. I've been trying to run the follow two scripts:

movie1.php
<?php
session_start();
$_SESSION['username']="Joe12345";
$_SESSION['authuser']=1;
?>
<HTML>
<HEAD>
<TITLE>Find my Favourite Movie!</TITLE>
</HEAD>
<BODY>
<?php
    $myfavmovie=urlencode("Come On!");
    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 the permissions";
    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 move is ";
    echo $_REQUEST['favmovie'];
    echo "<br>";
    $movierate=5;
    echo "My movie rating is: ";
    echo $movierate;
?>
</BODY>
</HTML>


You will probably notice that 'authuser' has a consistent value but i still get the No Permission warning. I also get this following error message in the log:
[error] [client 127.0.0.1] PHP Notice: Undefined index: authuser in C:\\Web\\moviesite.php on line 4, referer: http://localhost/movie1.php.

Somebody please help!!
 
Old November 29th, 2006, 11:06 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there,

The following line:
echo "<a href='http://localhost/moviesite.php?favmovie=$myfavmovie'>";

needs to be changed for:

echo "<a href='moviesite.php?favmovie=$myfavmovie'>";

cheers...







Similar Threads
Thread Thread Starter Forum Replies Last Post
session error - php.ini file bogins Beginning PHP 8 January 5th, 2008 04:59 PM
PHP session cookie ajit Beginning PHP 0 October 23rd, 2007 11:56 PM
Session Error / PHP.ini file socoolbrewster Beginning PHP 5 June 8th, 2006 04:18 AM
How do i handle session variables in php goutamj PHP How-To 2 July 27th, 2005 08:37 PM
Session Error in PHP Randhy MySQL 8 December 17th, 2004 07:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.