Wrox Programmer Forums
|
BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 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 April 19th, 2009, 02:09 PM
Registered User
 
Join Date: Apr 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 2, pg 39

Hi, i need help ha ha,

My session_start() is not enabled or not working for some reason. here is my code,

movie1.php

Code:
<?php
session_start();
$_SESSION['username'] = 'Joe12345';
$_SESSION['authuser'] = 1;
?>


<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title> Find my favorite Movie!</title>
</head>

<body>

<?php

$myfavmovie = urlencode('life of Brian');
echo "<a href=\"moviesite.php?favmovie=$myfavmovie\">";
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 xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>My Movie Site - <?php echo $_GET['favmovie']; ?></title>
</head>

<body>
<?php
echo 'Welcome to our site, ';
echo $_SESSION['username'];
echo '! <br/>';
echo 'My favorite movie is ';
echo $_GET['favmovie'];
echo '<br/>';
$movierate = 5;
echo 'My movie rating for this movie is: ';
echo $movierate;
?>
</body>
</html>
Any help would be great. When i take out the session_start() it will work, just will not pass variables obviously.I think it has to do with php.ini, im not sure, im new.

Thanks!
 
Old April 20th, 2009, 02:24 PM
Registered User
 
Join Date: Apr 2009
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Default

It looks like you've added an extra [ in your if statement...

it should read

PHP Code:
if ($_SESSION['authuser'] !=1) { 
its usually the simple stuff...
The Following User Says Thank You to sgtwwilson For This Useful Post:
Bodman@live.ca (April 21st, 2009)
 
Old April 21st, 2009, 01:42 AM
Registered User
 
Join Date: Apr 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Thanks

Thank you!, :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Undefined session variables Ch.2 pg. 38-39 outtaMyBlood BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 2 March 14th, 2009 02:19 PM
Chapter 3 pg 95 al2000 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 August 4th, 2008 09:18 PM
Chapter 4 Pg 117 Try It Out workib ASP.NET 3.5 Basics 1 April 7th, 2008 12:49 AM
Chapter 4 pg 131 cpkaiser BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 May 2nd, 2004 01:50 PM





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