Wrox Programmer Forums
|
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 February 3rd, 2010, 07:36 PM
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter: 1 (You provided invalid data)

Hi guys !

i wrote the chap 1 script every thing is fine, i put simple fill the registration form but after click verify link

this msg comes up

You provided invalid data.

Please try again.


any idea what i am doing wrong

have look by self:
http://www.mardan.org.uk/book/public_files/register.php

Please response thanks

Last edited by kmyousafzai; February 3rd, 2010 at 08:23 PM..
 
Old February 4th, 2010, 04:51 AM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi kmyousafzai,

Thank you for putting in the link, that is helpful.

I registered on your site twice in row, first as
kenjphpforumtesting and then as kenjphpsecondtry.
What I noticed was each time I registered, the uid
value in the verify.php string was always 0.

For example,

Be sure to verify your account by visiting verify.php?uid=0&token=T2L30

It should not be zero.
That is why you were getting the error you
received. $user->setActive($_GET['token'] returned false. In
User.php, you can see that the setActive function tries to select
the token associated with the user id, and it cannot match a
token with a user id of 0.

Check your database and verify that these user names are
in there and have a reasonable userId.
If they do, then in register.php file, go to the section
where it has the comment

// create an inactive user record.

Then check the value of $user->userId, it should not be zero.
Be sure to check it's value in the line where you set
$GLOBALS['TEMPLATE']['content'] = ...Thank you for registering...

I hope this helps.
 
Old February 4th, 2010, 01:13 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi kmyousafzai,

Here is a little bit more to continue my previous reply.

If the $user->userId is zero, and you don't see the users
in the database, then trace it back like this.
Go to User.php, function setInactive(), that function
will call function save(), which is also in User.php.
In function save(), you should drop into the else block where you INSERT
into the database. The line
Code:
  $this->uid = mysql_insert_id($GLOBALS['DB']);
will give you the user id. mysql_insert_id is a
php call that will get the id generated for an
AUTO_INCREMENT column.

You might want to look at the thread before this one,
"ch1 userId", by nativerun. We had a discussion
in there about userId.

kenj
 
Old February 7th, 2010, 08:07 PM
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Still have same problem

Quote:
Originally Posted by kenj View Post
Hi kmyousafzai,

Here is a little bit more to continue my previous reply.

If the $user->userId is zero, and you don't see the users
in the database, then trace it back like this.
Go to User.php, function setInactive(), that function
will call function save(), which is also in User.php.
In function save(), you should drop into the else block where you INSERT
into the database. The line
Code:
  $this->uid = mysql_insert_id($GLOBALS['DB']);
will give you the user id. mysql_insert_id is a
php call that will get the id generated for an
AUTO_INCREMENT column.

You might want to look at the thread before this one,
"ch1 userId", by nativerun. We had a discussion
in there about userId.

kenj
---------------------------------------------------
Hi Kenji thanks for help but i am still stuck ,

-----------------------------------------

In function save(), you should drop into the else block where you INSERT
into the database. The line

Code:
$this->uid = mysql_insert_id($GLOBALS['DB']);


i tried alot but still have same problem, could you explain ( drop in to the else block where ...)

where i should need to drop ,?


thanks
 
Old February 9th, 2010, 08:26 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi kmyousafzai,

What I meant was if the "if" statement is not true,
it will then go to the else statement and start executing
the code in that else block.
For debugging purposes you may want to add some
print statements to your code, just so you can see what
is happening as your code executes.

Before you do that, you should first look at the database
and verify that the users got added.

You may also want to check your error logs.

If you could let us know how all this goes, that
would be helpful.
 
Old February 14th, 2010, 01:04 PM
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had faced some hurdle in a few files.

1= db.php

Define (‘DB_TBL_PREFIX’,’WROX_’);

In this section i have changed

Define (‘DB_TBL_PREFIX’, ’’);


2= User.php

private $uid;

In this section i have changed

public $uid;

and

$user->uid =$user_id;

In this section i have changed

$u ->uid;

and $user = new User(); To change $u =new User();

and in public function setInactive()

I paste the $this->uid = mysql_insert_id($GLOBALS['DB']);

The bottom of mysql_query($query, $GLOBALS['DB']);


3= Registration.php

Again in this section i changed

$user-> userid to change $u =uid


Now every thing going fine ... thanks
 
Old February 26th, 2010, 09:44 PM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi kmyousafzai,

In my view, these changes may be setting you
up for problems later on. I would not make them.
I would revert to the original code and
troubleshoot from there.

Okay, the change to db.php, would be okay if you
made sure it was changed in every file and the
database.

In User.php, making variables public in the User class goes against the
design of the object oriented model being used here. The program is
designed such that those variables are private to User class.

In register.php it appears you are trying to use the
mysql_insert_id that was in the save function, and moving
it into the set_inactive. This causes all kinds of unwanted
changes in the logic. By moving it to setInactive, the call
to mysql_insert_id
bypasses the logic of calling verify.php and setting the user
to active and saving the user.

I think if you tried the troubleshooting outlined in the last thread,
you might be better off. In particular you need to find out what's
going on with the $user->userId variables on page 15, around lines
16 and 17.

regards,
kenj
 
Old April 10th, 2010, 09:27 AM
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Forgot passowrd ?

Hi Guys !

I am working on forgot password section, when i want to retrieve new password , and put username and after successfully received email with new password, however the new password doesn’t work. Any idea what the logic ..?
 
Old April 10th, 2010, 11:57 AM
Authorized User
 
Join Date: Jul 2009
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi Kmyousafzai,

Good to hear from you.

I made a post on this a while back.
See the post entitled "User registration forgotpass.php"
I also submitted it in the errata section at that time,
and Wrox has acknowledged it.

Here's a paste in from Wrox's errata
on this book.

Error in Code
Chapter 1, User Registration, the forgotpass.php file:

// store new password
$user->password = $password;
$user->save();

Should be:

// store new password
$user->password = sha1($password);
$user->save();
 
Old September 8th, 2010, 09:57 AM
Authorized User
 
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default I am running into the same problem

I am running into the same problem, except in my case, nothing is being written to the database so my user id is always coming back as a null. I am using the code downloaded from the wrox site for both the User class and the register.php. They don't seem to be playing well together. I am just starting to investigate this and I was hoping someone else had alread found a solution. When I figure out what is causing the problem, I will post a fix for it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 5 - Command Line Error. Invalid parameter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:00 AM
Chapter 8,Invalid authorization omom2002 BOOK: Beginning VB.NET Databases 1 May 27th, 2008 05:04 AM
Cant seem to compile (small with source provided) noob1 JSP Basics 1 September 20th, 2003 03:55 AM
cannot check data provided by a form scifo Beginning PHP 1 August 6th, 2003 11:06 AM





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