For storing new user information in database, first we have to create a new table in database which contain user name,email,password fields.
The logic of the controller is written below. In below code we have create a function registration ,so we have to create a view with similar name with .ctp extension. View will contain our registration form which will send user information to the controller by using POST method.
<?php
App::uses('Controller','Controller');
class UsersController extends AppController
{
function registration(){
if ($this->request->is('post')) { // checking form data is send by using post
$this->User->create(); // function will save the data of the user in the database
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been created'));
$this->redirect(array('action' => 'login'));
} else {
$this->Session->setFlash(__('The user could not be created. Please, try again.'));
}
}
}
0 Comment(s)