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:
if ($user->userId && $user->password == sha1($_POST['password']))
if ($user->userId && $user->isActive && $user->password == sha1($_POST['password']))
forgotpass.php lines 63 and 64:
$user->password = $password;
$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
$user = User::getById();
$user = User::getById($_SESSION['userId']);
4. main.php line 9
removed comment slashes from
5. main.php line 36
<td><input type="submit" value="Save"/></td>
<td><input type="submit" value="Save"/> <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:
// 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">firstname.lastname@example.org</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.