Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 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 13th, 2006, 09:16 AM
Registered User
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chap. 2 Page 52-53 session

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. Is there a setting in the php.ini that i'm not a aware of?

Somebody please help!!

 
Old November 13th, 2006, 01:59 PM
Registered User
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've had a look into C:\Temp folder, which is where the session.path points to. I've noticed that when trying to run the script two session files are created. One with the "username|s:8:"Joe12345";authuser|i:1;" and second one being empty. I'm guessing that script looks into the empty session file, which is why I keep getting the "No permissions..." message. Is there anyway to get the script to a certain session file or any way to fix this problem?

 
Old November 30th, 2006, 03:07 PM
Authorized User
 
Join Date: Jul 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you get an answer to this issue yet? if not i will take a look at it for you (i dont want to look if you resolved it already, please let me know - and i will help you out - just post a Yes No).






Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 - Page 52, 53 Chudz BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 8 February 19th, 2006 07:09 PM
Ch2 52-54--passing session variables dprice BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 September 26th, 2005 07:01 AM
Ch 2 Page 53: Undefined index: authuser Airidh BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 25 February 22nd, 2005 07:34 PM
Chap. 11 - Try It Out, Session Tracking with PHP Tachyon BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 5 June 17th, 2004 02:02 PM





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