Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
|
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 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 July 14th, 2012, 08:12 AM
Registered User
 
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:[email protected]?subject=Boronczyk Registration">[email protected]</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..





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





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