O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — adding functionality for users to log in

We're going to go through this slowly, but I think you're going to love how quickly we're able to add this functionality with all of the code we've written so far.

  1. Open classes/user.php.
  2. Create a public function called login to which we can pass our plain-text $password as a parameter.
    public function login($password) {
    }
    Create a new bones object and set the database to _users.
    public function login($password) {
    $bones = new Bones();
    $bones->couch->setDatabase('_users');
    
    }
    
  3. Create a try...catch statement for our login code to live in. In the catch block, we are going to catch the error code 401. If it is triggered, we want to tell the user that their login was incorrect.
    public function ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required