How to automatically login after registration

In this 'how to' tutorial you will learn how to implement an automatic login operation after registration. This is useful when registration does not require activation and each new user will have the right to use the account right after creation, without having to login first.

If you have the MX Kollection 3 bundle installed, then you have all the needed tools to build this application. Otherwise, the following separate products should be installed on your computer in order to complete the How to automatically login after registration tutorial:

The estimated completion time for this tutorial is 20 minutes. It also depends on your authoring knowledge with Dreamweaver and MX Kollection 3.

 

This tutorial topic contains the following sections:

Plan the application

The database used for this tutorial contains a single table which stores user details:

 

Note: The database diagram in the image above was built with MX Query Builder (also referred as QuB) to better illustrate the database structure. You do not need to build it in order to complete this 'how to' tutorial.

 

The user_usr table stores the following information:

To quickly create the database structure, use the scripts provided in the zip package (either .sql or .mdb) corresponding to your database server. You can find the scripts in the \tutorials\_HOW_TO\Automatically login after registration\db\ folder.

There is one record already inserted in the user_usr table. In order to test your application (the login form), login with the username and password corresponding to this record: username - john, password - root.

 

For this tutorial you will create three pages:

  1. index - the page to which the user will be redirected after a successful login.

  2. login - the page containing the user login form.

  3. register - the page with the user registration form.

Create these pages in your site root as empty files. You will add content to each of them later on.

Before starting to work on the actual content though, you must define a Dreamweaver database connection to the table created earlier. Configure it to use your database server:

 

Configure the login settings

In order to add user authentication to your system, you must first configure the Login Settings. In MX Kollection 3, all user authentication options are managed in a central place, in the InterAKT Control Panel, Login Settings. Open this window and configure each tab as explained below:

  1. In the Options tab check the Encrypt password option to store encrypted passwords:


                   

  2. In the Database tab configure the table columns to use for the user authentication:


     

  3. You can safely skip the Session tab (leave its default settings).

  4. In the User levels tab define the pages to open when the login fails or is successful:


     

  5. Click OK to close this user interface and to apply the changes made to the login settings.

Create the user login form

It is time to build the user login form, that allows users to enter their credentials and view the index page.

To build the login page, follow the steps below:

  1. Open the login page in Dreamweaver.

  2. Apply the Login Form Wizard from the MX Kollection tab of the Insert bar.

  3. If you have already defined the Login Settings, you can skip the first step. Otherwise, click the Change Login Settings button to open the user interface and configure it as shown here.


                           

  4. In the second step of the wizard check both options: Create "Remember me" checkbox and Create "Forgot password" page:


     

  5. Click Finish when done to add the login form to the page. Save the page and upload it to the server. Test it by using the record already inserted in the database: username - john, password - root. You will be redirected to the index page (empty for now, but you will be build it here) once you press the Login button:

 

In the next topic of the tutorial you will build the user registration page, which will also login the user (not only register) and load the index page.