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 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 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 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!
Reply With Quote
  #2 (permalink)  
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...
Reply With Quote
The Following User Says Thank You to sgtwwilson For This Useful Post:
Bodman@live.ca (April 21st, 2009)
  #3 (permalink)  
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!, :)
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
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



All times are GMT -4. The time now is 10:54 AM.


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