Happy Coding

Today we will learn about how to make simple registration form in CakePHP.

For starting with this tutorial you must know the concept of MVC in CakePHP and naming conventions if you don’t know you can just learn here.

Step1

Step2

Create fields in database using following SQL Statement.

 

Step3

After creating database you should proceed with following.

Create model ‘user.php’ in app/models  becuase our table is users. The code for user.php is as follows

This above code set will extends the AppModel class with name User. Which we will use in the controller part for doing actions on this model. Model is the part where the database logic resides so to make actions on the users table we must declare name here and use it in controller. Here we declared User as a name. So in controller our code will look like $this->User->save(data).

Step4

Now create the view ‘register.ctp‘ of Registration form in app/views/users/ with following code. Make sure that the name of the inputs must be same as the name of column sin our users table.

Here we are using simple HTML for creating form. But CakePHP have its own Helpers which make this process so much simple but now we are not familiar with Helpers so we are not using.

Step5

Now the model and view are completed. But the part which is so much important i.e. logic part is remaining. Create ‘users_controller.php‘ in app/controllers with following code.

Now after doing whole this open your browser and access register view by entering users/register/ this will open the registration form. After filling the registration form click on register button. In controller it will check for the register function because we have mentioned the action of form as ‘../register’ . And register function in controller will save the data from the form using $this->User->save($this->params[‘form’]) statement.

The statement above will create the INSERT statement as follows

And you will get the message as

Registration Successful

Hooray we have done with it 🙂

Enjoy!!

Simplest registration form in CakePHP UG Programming
Happy Coding Today we will learn about how to make simple registration form in CakePHP. For starting with this tutorial you must know the concept of MVC in CakePHP and naming conventions if you don't know you can just learn here. Step1 Step2 Create fields in database using following SQL Statement.   Step3 After creating database you...
Happy Coding Today we will learn about how to make simple registration form in CakePHP. For starting with this tutorial you must know the concept of MVC in CakePHP and naming conventions if you don't know you can just learn <a href="http://book.cakephp.org/1.3/en/" target="_blank">here.</a> <strong>Step1</strong> [crayon-5a2f283042725345703747/] <strong>Step2</strong> Create fields in database using following SQL Statement. <code> </code> [crayon-5a2f28304273a663725327/]   <strong>Step3</strong> After creating database you should proceed with following. Create model '<strong>user.php'</strong> in <strong>app/models  </strong>becuase our table is users. The code for user.php is as follows [crayon-5a2f283042740741059697/] This above code set will extends the AppModel class with name User. Which we will use in the controller part for doing actions on this model. Model is the part where the database logic resides so to make actions on the users table we must declare name here and use it in controller. Here we declared User as a name. So in controller our code will look like $this-><strong>User</strong>->save(data). <strong>Step4</strong> Now create the view '<strong>register.ctp</strong>' of Registration form in <strong>app/views/users/ </strong>with following code. Make sure that the name of the inputs must be same as the name of column sin our <strong>users</strong> table. [crayon-5a2f283042746781323280/] Here we are using simple HTML for creating form. But CakePHP have its own Helpers which make this process so much simple but now we are not familiar with Helpers so we are not using. <strong>Step5</strong> Now the model and view are completed. But the part which is so much important i.e. logic part is remaining. Create '<strong>users_controller.php</strong>' in <strong>app/controllers </strong>with following code. [crayon-5a2f28304274b029516497/] Now after doing whole this open your browser and access register view by entering users/register/ this will open the registration form. After filling the registration form click on register button. In controller it will check for the register function because we have mentioned the action of form as '../register' . And register function in controller will save the data from the form using <strong>$this->User->save($this->params['form']) </strong> statement. The statement above will create the INSERT statement as follows [crayon-5a2f283042751083113456/] And you will get the message as <strong>Registration Successful</strong> Hooray we have done with it 🙂 Enjoy!!