View Single Post
  #3 (permalink)  
Old December 7th, 2012, 09:06 PM
null null is offline
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

As I don't see a point in creating a new thread I'm just gonna post my doubts here, hope you don't mind MRGLENN.

My problem is even after I have added the 3 colums to the 'contacts' table (user_name, password and access) I'm still having difficulties putting the example to work.

The first problem is within the _verifyInput() function in the Contact class.
When I edit a contact to change a password it enters in the following elseif statement in the function:

elseif (self::getContactIdByUser(trim($this->user_name))) {
    $error = true;
therefore assigning true to $error and not allowing me to update the existing contact information.

The other problem is when I create a new contact and give an username and password for it all the existing contacts in the table will also have their user_name and password fields changed to the username and password I provided for the new contact.

I think it's happening this way due to the following code, in the addRecord() function:

if ($connection->query($query)) { // this inserts the row
        // update with the user name and password now that you know the id
        $query = "UPDATE contacts 
        SET user_name = '" . Database::prep($this->user_name) . "', 
        password = '" . hash_hmac('sha512',
          $password . '!hi#HUde9' . mysql_insert_id(), 
          SITE_KEY) ."',
        access = '" . Database::prep($this->access) . "'";
because even though it is said it will update with the username and password now that the ID is known, we're not setting a WHERE clause to edit only that specific row, causing all the contact rows to be updated to the user_name and password values I entered for the new contact.

If anyone could point me in the right direction with these points, I'd appreciate it.

Thanks in advance

EDIT: This way already addressed in another thread, probably should have searched first. Here's the link for the correction.

Last edited by null; December 8th, 2012 at 06:59 AM..
Reply With Quote