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 — handling simple user signup

Let's go through the signup process step-by-step, in which we'll rebuild the code in our signup POST route from scratch. I'll explain each piece of code on the way, and then, we will do a full recap at the end of this section.

  1. Open index.php, and start by collecting the simple fields: full_name, email, and roles. The fields full_name and email will come directly from the form submission, and roles we will set to an empty array because this user has no special permissions.
    post('/signup', function($app) {
    $user = new User();
    $user->full_name = $app->form('full_name');
    $user->email = $app->form('email');
    $user->roles = array();
    
  2. Next, we'll want to capture the username that the user submitted, but we'll ...

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