Skip to main content

skip to main content

developerWorks  >  Open source  >

Cook up Web sites fast with CakePHP, Part 1: Getting started

Quick and easy PHP rapid-development aid

developerWorks
Go to the previous pagePage 6 of 11 Go to the next page

Document options
PDF format - Fits A4 and Letter

PDF - Fits A4 and Letter
645 KB (35 pages)

Get Adobe® Reader®

Sample code


My developerWorks needs you!

Connect to your technical community


Rate this tutorial

Help us improve this content


Filling in the gaps

So far, users can register for your application and see who has already registered. The application needs some filling in. Using the skills you've learned so far, try filling in some more functionality. Check out Part 2 for examples of the following.

Login

The login view should gather the user login information and submit it to the users controller. The users controller should look to see if the user is in the database and verify that the password is correct. If the user has correctly logged in, write the username to session and send the user to the index action.

Hints:

  • Use the built in $this->User->findByUsername($your_username_variable_here) to search for the user in the database
  • Write the user's name to Session with $this->Session->write('user', $your_username_variable_here)


Back to top


Index action

The index action should check to see if the user's name has been written to the session. If the user's name has been written to the session, pull that information from the database and present the user with a customized greeting. If the user has not logged in, direct him to the login action.

Logout

The logout action should delete the user's username from the session and forward the user to the login action.

Bonus

Modify the register action to automatically log the user into the system and forward the user to the index action. Modify the register and login actions to use hashed passwords, rather than saving your passwords in the database as plain text.

Don't worry too much if you get stuck. Part 2 provides sample solutions to these problems. Then you'll jump right in and build out the Tor application product gallery.

Happy coding!


Go to the previous pagePage 6 of 11 Go to the next page