Hi GallowayAC,
Try to trace it back.
On page 15, about line 7, you are
instantiating a user object.
PHP Code:
$user = new User();
On that same page, about 5 lines further down,
you are calling the method setInactive().
PHP Code:
$token = $user->setInactive();
At this point, you do not have a user id yet,
but you will have one after returning from this method.
Let's look at the setInactive method.
It starts on page 8, about line 9.
PHP Code:
public function setInactive()
In this method you call the method save().
This is on page 8, about line 12
"$this" refers to the user object you instantiated up above.
You still do not have a user id yet, but you will have one
after returning from this method.
Let's look at the save method
It starts on page 7, about line 23
PHP Code:
public function save()
As you enter this method you do not have a userid, so
you will enter the else block. Assuming your query is
successful, you drop into the nested if statement
to the line
PHP Code:
$this->uid = mysql_insert_id($GLOBALS(['DB']);
This is the point where the user id is generated. When this statement
is done executing successfully you will have your user id
for the user you instantiated up above (As I said "$this" refers
to that object)
Put a print statement before this statement and make sure you
are getting to this line of code.
Put another print statement right after this line and print the
user id. Run your program a couple of times and
verify that you are getting reasonable user ids that keep
incrementing on each run of your program. If not check that
you have set up your database tables correctly. In the WROX_USER
table make sure USER_ID has AUTO_INCREMENT.
If this line of code is successful, then put in print statements along the way
through the flow of logic mentioned above and see where your
user id disappears.
Based on what you have said, that you had the correct information in the
pending table, it seems you were successful in the setInactive method. You
are probably losing the value higher up in the logic flow. Your problem
would not be in verify.php as you are not passing it a good userid. You call
to verify should have something like this
PHP Code:
verify.php?uid=5&token=5DPPM
See the post
ch1 userId, about the second reply down.
There is a discussion about the line
PHP Code:
$this->uid = mysql_insert_id($GLOBALS(['DB']);
In that reply there is also a discussion about the
use of $this->userId and $this->uid
There are some mistakes in Chapter 1. Check the errata
and be sure to make those changes.
I hope this helps.