Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 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 Display Modes
  #1 (permalink)  
Old July 14th, 2012, 08:12 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How I got Chapter 1 code to work (My summary of corrections)

Hello folks, I ran into many of the common problems with the source code. I thought I would summarize the changes that I made to the file downloads in order to get things up and running. Many of these corrections come from other helpful posters here in this forum:

1. I made the changes that are in the errata. These are (as of July 14 2012):

login.php Line 21:
PHP Code:
if ($user->userId && $user->password == sha1($_POST['password'])) 
Should be

PHP Code:
if ($user->userId && $user->isActive && $user->password == sha1($_POST['password'])) 
and
forgotpass.php lines 63 and 64:

PHP Code:
$user->password $password;
$user->save(); 
Should be:
PHP Code:
$user->password sha1($password);
$user->save(); 
2. I replaced the 401.php with the file of the same name from Chapter 2.

3. main.php line 13

PHP Code:
 $user User::getById([1]); 
to
PHP Code:
$user User::getById($_SESSION['userId']); 
4. main.php line 9 removed comment slashes from
PHP Code:
include '401.php'
5. main.php line 36
replaced
HTML Code:
   <td><input type="submit" value="Save"/></td>
with
HTML Code:
   <td><input type="submit" value="Save"/>&nbsp;&nbsp;<a href="login.php?logout">LOG OUT</a></td>
6. register.php line ~88 I switched out the ineffective link verification to the email verification at around line 88, which looks like this as I entered it from the book:
PHP Code:
            // create an inactive user record
            
$u = new User();
            
$u->username $_POST['username'];
            
$u->password $password;
            
$u->emailAddr $_POST['email'];
            
$token $u->setInactive();

            
$message 'Thank you for signing up for an account! Before you' .
                
' can login you need to verfy your account. You can do so ' 
                
'by visiting <a href="YOUR FILE STRUCTURE/ch_01/public_files/verify.php?uid=' 
                
$u->userId '&token=' $token '.';
            
            if (@
mail($u->emailAddr'Activate your new account'$message))
            {                 
            
$GLOBALS['TEMPLATE']['content'] = '<p><strong>Thank you for ' .
                
'registering.</strong></p> <p>You will be receiving' .
                
' an email shortly with instructions on activating your ' .
                
'account.</p>';
               }
    
    
// there was invalid data
            
else
        {
        
$GLOBALS['TEMPLATE']['content'] .= '<p><strong>There was an ' .
            
'error sending you an activation link.</strong></p> ' .
            
' <p>Please contact the site administrator at ' .
            
'<a href="mailto:YOU@YOUREMAIL.com?subject=Boronczyk Registration">blake@blakeketchum.com</a> for ' .
            
'assistance.</p>';
              } 
I think that's all the changes that I made. I hope this helps. There may be something I forgot, but I for one, am glad to put this chapter to rest.

Last edited by podzol; July 14th, 2012 at 08:30 AM.
Reply With Quote
Reply


Thread Tools
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 4 - Summary Excercises soopahNerd BOOK: Beginning Visual C# 2010 2 May 23rd, 2011 10:13 AM
Cannot Get PHP Code Example in Chapter 1 to Work rhieger Beginning PHP 5 July 27th, 2008 11:16 AM



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


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