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 January 12th, 2005, 05:16 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default sessions not being passed Chapter 2

I copied movie1.php from the book. However the sessions info is not being passed. http://piano.cshore.com/2005/movie1.php

Here's my phpinfo.php file http://piano.cshore.com/2005/phpinfo.php

movie1.php

<BODY>
<HTML>
<?php
session_start();
$_SESSION['username']="Joe12345";
$_SESSION['authuser']=1;
?>
<HTML>
<HEAD>
<TITLE>Find my Favorite Movie!</TITLE>
</HEAD>
<BODY>
<?php
     $myfavmovie=urlencode("Life of Brian");
     echo "<a href='http://piano.cshore.com/2005/moviesite.php?favmovie=$myfavmovie'>";
     echo "Click here to see information about my favorite movie!";
     echo "</a>";
?>
</BODY>
</HTML>

moviesite.php

<BODY>
<HTML>


<?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, you loser!";
     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>


 
Old February 27th, 2005, 06:00 AM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes I have the same problem as well. sorry no answers :(

 
Old March 3rd, 2007, 01:56 PM
Registered User
 
Join Date: Dec 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

me too, and no one seems to want to help either :(

chris
 
Old March 7th, 2007, 11:42 PM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Same here, the variable value '1' from $_SESSION['authuser'] doesn't get passed to the moviesite.php. It simply returns as NULL. Can someone please comment on that? Thanks.
 
Old March 13th, 2007, 11:15 PM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The session_start() function won't work unless it is the second line of the page (<php? ) should be at top.

 
Old May 19th, 2007, 04:41 PM
yue yue is offline
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yue
Default

This question also kept me busy for about a few hours. even reinstalling xampp all over. but none the less i finally understand the riddle. I didnt change anything into the php.ini from the xampp version. (i don't know the number sorry but its the one of may 2007)

In moviesite.php I changed

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

although we now ask whether the authuser is not equal to one. it does let you show the page when this condition is true and when it is false it does not show you the page...

well I know its not a solution but at least we know where the problem lies. I hope someone will be able to fix this later :) and i hope this will be the only error in the book ^^


 
Old June 27th, 2007, 03:28 PM
Registered User
 
Join Date: Oct 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The book suggests the opening tag for php script must be the first line of the file. I found that blank lines don't bother my programs but I do agree "session_start();" should be the first line after "<?php".
I am not sure I understand the problem in the last post so if you can clarify a little I will check it on my machine.

Namaste,

Kevin Tough






Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 16 - Problems with sessions. kb90 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 April 11th, 2008 09:07 AM
Value in Querystring not being passed u_heet Classic ASP Professional 2 September 16th, 2004 07:15 AM
Mixing classic ASP sessions with ASP.NET sessions scorpion_king General .NET 2 August 4th, 2004 08:20 AM
wrong passed parameter apek PHP How-To 1 January 11th, 2004 01:08 PM
All My Checkboxes are passed as "on", whether or n WebDevel Javascript How-To 1 December 9th, 2003 10:40 AM





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