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 May 30th, 2004, 09:10 AM
Registered User
 
Join Date: May 2004
Location: , , .
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?






Reply With Quote
  #2 (permalink)  
Old May 30th, 2004, 09:29 AM
Registered User
 
Join Date: May 2004
Location: , , .
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

Reply With Quote
  #3 (permalink)  
Old May 31st, 2004, 09:35 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
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

<><
Reply With Quote
  #4 (permalink)  
Old May 31st, 2004, 12:41 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
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
::::::::::::::::::::::::::::::::::::::::::
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
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



All times are GMT -4. The time now is 01:40 PM.


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