Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 23rd, 2005, 02:59 PM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dprice
Default Ch2 52-54--passing session variables

I'm running Apache/2.0.54(Debian Linux) with PHP/5.0.4. I know this is not the php5 forum and, as I'm just beginning with AMP, I'm hoping that this book will suffice until I can acquire the 5 series book. That said, I'm stuck on Ch2 pgs 52-54.

Clicking the link in movie1.php brings up the "Sorry...." page, so I know that the username and authuser variables are not being passed. The session.save_path is set to default at /tmp, and viewing that directory does indeed reveal a newly created session document. The problem, I think, lies in that there is no information in the document, therefore, no variables are being being passed to the moviesite.php page. What settings need to changed/made/adjusted in order to fix this problem? Thank you for any assistance. The code is listed:

movie1.php
Code:
<?php
session_start();
$_session['username'] = 'Joe12345';
$_session['authuser'] = 1;
?>
<html>
<head>
<title>Find My Favorite Movie</title>
<body>
<?php
    $myfavmovie=urlencode("Life of Brian");
    echo "<a href='http://localhost/exp/moviesite.php?favmovie=$myfavmovie'>";
    //echo "<a href='http://localhost/exp/sessiontest.php'>";
    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!";
        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>
[/code
Reply With Quote
  #2 (permalink)  
Old September 24th, 2005, 04:48 AM
Authorized User
 
Join Date: May 2005
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Correct me if I'm wrong, but shouldn;t the session superglobal be $_SESSION not $_session or is that just a typo?

Reply With Quote
  #3 (permalink)  
Old September 24th, 2005, 02:25 PM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dprice
Default

Thanks for the response. Regarding the caps vs. noncaps, I had thought of that, however, I'm receiving the same results (or lackthereof) whether it's $S_SESSION or $_session. It may be that it's supposed to be caps, but the /tmp session file remains empty regardless.

Reply With Quote
  #4 (permalink)  
Old September 26th, 2005, 07:01 AM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dprice
Default

It seems the variables are case sensitive. $_SESSION != $_session. Having been frustrated by this problem through the weekend, I opted simply to start over. I re-did the .php files in lowercase which did not work, deleted the files and used uppercase which did work.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing session variables from login page. captainzorro Classic ASP Components 1 April 23rd, 2008 11:54 PM
passing variables through session dmlocke Beginning PHP 4 May 4th, 2005 10:35 PM
Passing Session Variables to the Next Page jim.sullivan@telus.net ASP.NET 1.0 and 1.1 Professional 1 August 1st, 2004 06:25 PM
Passing Session Variables to the Next Page jim.sullivan@telus.net Classic ASP Databases 2 August 1st, 2004 01:59 PM



All times are GMT -4. The time now is 04:57 PM.


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