Adding a login to your web site
Quick 'n Easy Web Builder has a complete built-in (PHP) login system which makes it possible to password protect one or more pages. In another tutorial we've explained how get started by using the Login Demo project: http://www.quickandeasywebbuilder.com/login_tools.html
In this tutorial we will describe the basics of the login tools without using the demo project.
To get a full understanding of the login tools we strongly recommend to read both tutorials!
Step 1 - Setting up the database
A login system with multiple users needs a database to store the data of the users (like name, email, password etc). So the first thing we need to do is setup the database. The login tools can use either a flat file database, where all data is stored in a text file (usersdb.php) on the server, OR a MySQL database.
The flat file database is probably the easiest to setup and this is the default option. However MySQL is more secure and recommended for advanced users. In this tutorial we use the text based database. If you want to use MySQL instead then please consult the help (Toolbox->Login tools->User Database) for detailed instructions.
A flat file database is basically just a text file on the server, so it can be created with any standard text editor:
1. Open a plain text editor and create an empty file named 'usersdb.php'.
Or you can download an example database here: http://www.quickandeasywebbuilder.com/support/usersdb.zip
(note that the file is zipped so you will need to unzip it first!)
2. Upload the file to the same folder as where you are going to upload your (protected) pages to. You can use then built-in FTP tool or any other FTP application to upload the file to the server.
3. After the file has been uploaded you need to modify the permissions of the file so the PHP script can write data to it.
The correct permissions are 757 or 777.
4. Alternatively you can use the file transfer tool of your host's control panel. There should be an option in your web hosting control panel to set write permissions. If it's not present you may need to contact your web hosting service and request write permissions for the file.
Step 2 - Creating users
There are 2 ways to create users:
• With the online administration tool (Login Admin). The administrator of the website will create the user accounts.
• With the Signup form (Login Signup). Users can create their own account by using the signup form.
Creating users with the admin tool:
1) Create a new page in your project.
2) Drag & drop the Login admin object to the page.
3) Configure the database: usersdb.php
4) Set the administrator password.
5) Publish the page to the web server.
Now visit the admin page on your website and log in. Click 'Create new user' to create a new user.
Important: If you cannot add new users then either the database is not in the correct folder or it has the wrong permissions!
Creating users with the signup tool:
The Signup object allows users to signup for a new user account.
1) Create a new page in your project.
2) Drag & drop the Signup object to the page.
3) Configure the database: usersdb.php
4) Setup how the account will be activated:
Account activation specifies whether to enable account activation by the administrator. If this option is 'Administrator' then new accounts will not be activate until the administrator enables them. If this option is "Automatic' then the account will be enabled immediately after the user has completed the form. If the ‘Email’ verification option is selected then the user must activate the account via a link in the confirmation email before it will be activated. This makes sure the specified email is valid. The confirmation link will automatically be generated. The text of the confirmation email message can be changed in the 'Email' section.
Step 3 - Creating the login page
The login page allows the user to login and either redirect the user to the protected page or an accces denied page (if the password is wrong).
1) Create a new page in your project.
2) Drag & drop the Login object to the page.
3) Configure the database: usersdb.php
4) Configure the destination page. Specifies the page that the user is directed to upon successful login.
5) Configure the error page. Specifies the page that the user is directed to upon failed login.
Step 4 - Protecting a page
Now that we have setup users we can protect pages by simply dragging the 'Protect page' object to the page.
1) Drag & drop the Protect Page object to the page you want to protect.
2) In the properties we need to configure where the user will be redirected to if the password is incorrect. Usually the error page displays a message like 'Failed to login, try again' and then provides a link back to the login screen.
It's also possible to restrict the page to specific users with the 'AllowUsers' property.
Here you specify the users who can access the page. You can enter a list of comma-delimited users: Bill,Steve,Gary
If you leave this property empty then all registered users have access to the page.
Step 5 - Logout
The Logout object gives the user the ability to log out. In the Logout Page property you can specify the page that the user is directed to upon log out.
Important note:
Because the login tools use PHP you must set the extension of the page to PHP! You can do this in Page Properties. You cannot test the login tools in local preview. You must publish the pages to a web server with PHP support!
What's next?
There are many other options available for the login tools like custom profile fields, edit profile, password recovery, change password etc.
For more information about these options please consult the help.
Related tutorials:
Getting started with the Login Tools
Customizing the Signup Form