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 May 30th, 2004, 09:10 AM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter 11, login

Hi,

Who has the login functionality as explained in chapter 11 working?

My index.php does not recognize me as a 'logged_user', even after I logged in.

1) index.php
session file is created, no username password available
unlogged_user.php is included.

2) user_login.php opens
a 2nd session file is created no username password available

3) username/password submitted in user_login.php
a 3rd session file is created, now containing username password data:

user_logged|s:8:"koen";user_password|s:5:"secret";

now, I am redirected to index.php (a 4th session file is created, without username/password data). Index.php does not (!) (AARRRGGHHHH! :() recognize any username password data and unlogged_user.php is included again!

Who can help me with this?

Kind regards,

Koen

PS. Can I download the code samples from chapter 11 from anywhere?






 
Old May 30th, 2004, 09:29 AM
Registered User
 
Join Date: May 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found the place to download the code.
Tried it with the downloaded code.
Same problem!
Does this code work for anyone?!?!

All help is appreciated!

Koen

 
Old May 31st, 2004, 09:35 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

My guess is that register_globals is off (which is probably a good thing). Instead of referencing to the session variables like $name try using a superglobal like $_SESSION['name'].

Let me know if this solves your problem.

Snib

<><
 
Old May 31st, 2004, 12:41 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Ok, register_globals doesn't have anything to do with the problem.

My guess is the page is relying on cookies to pass the session id and you probably don't have cookies enabled. In most modern browsers cookies are turned off by default.

Code:
          header ("Refresh: 5; URL=" . $_POST['redirect'] . "&sid=".session_id());
          echo "You are being redirected to your original page request!<br>";
          echo "(If your browser doesn't support this, <a href=\"" .
               $_POST['redirect']. "&sid=".session_id()."\">click here</a>)";
The session id is required to tie the session data to the user, if the id is not passed a new session will be created every time. By default this is done with cookies, every time a call to session_start is made a cookie is output containing the session id. Otherwise the session id needs to be hard coded into the page with a query string or hidden input field.

Such as:
echo "<a href='index.php?sid='".session_id()."'>Click here</a><br />\n";

Or:
echo "<input type='hidden' name='sid' value='".session_id()."' />";

Try that and let me know how it goes!

HTH!

Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter-11 Carlw BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 October 16th, 2008 02:08 PM
chapter 11 figure 11-7 relative positioning pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 November 29th, 2007 06:11 AM
Chapter 11 mhanson BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 0 July 10th, 2007 08:40 PM





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