p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 (http://p2p.wrox.com/book-php-mysql-create-modify-reuse-isbn-978-0-470-19242-9-406/)
-   -   How I got Chapter 1 code to work (My summary of corrections) (http://p2p.wrox.com/book-php-mysql-create-modify-reuse-isbn-978-0-470-19242-9/87992-how-i-got-chapter-1-code-work-my-summary-corrections.html)

podzol July 14th, 2012 08:12 AM

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'])) 

forgotpass.php lines 63 and 64:

PHP Code:

$user->password $password;

Should be:
PHP Code:

$user->password sha1($password);

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]); 

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
HTML Code:

  <td><input type="submit" value="Save"/></td>
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 ' .
// there was invalid data
$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 ' .

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.

All times are GMT -4. The time now is 10:38 PM.

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