Computer Programming web Web programming Tips

User Authentication, User Registration Script. PHP

By Sergey Skudaev

I am offering free a complete website with users registration, Authentication and authorization and ability to add comments if you by Learn PHP Programming by Examples. The demo web site has two levels of users: regular user and admin user. Some web pages can be access by all users and some web pages can be accessed by all users.

Additionally, the demo web site includes 3 css style files with different color schemas and for 3 columns page layout with web page templates.

You do not have to know PHP programming to use my set of templates. To make your web site capable to register visitors and set to visitors different permissions you have to perform the following steps.

1. Create mail account on your hosting control panel.

How to set email account in your control panel

2. Create MySQL database and database users.

How to create MySQL database in your control panel

3. Create username table in MySQL database using phpMyAdmin. Detailed instruction will be provided.

How to use phpMyAdmin

Your hosting control panel has phpMyAdmin installed and you can use it right away to access you database and create tables. Open SQL window and paste my script included in the usernames.sql.txt file. Click Go button. The usernames table will be created.

Create auth directory in your web site root directory and unzip file there. The Root directory is where all your web page files are stored. Usually it is public_html.

4. Edit "connect.php" file. Enter your database name, your user name, your user password created in step 2. Enter your hosting email address created in step 1.

It should looks like that:

$hostname = "localhost";

$dbuser = "myuser";

$dbpassword = "mypassword";

$dbname = "mydatabase";


There should not be any space character after ?>

If you want that your particular web page was accessible only to registered users include the "auth.php" file on the top of this page. See the "protected_template.php" file as example. The web page must have extension .php and not .html.

If you want that your particular web page was accessible only to admin users, include the "adminauth.php" file on the top of this page. See the "admin_template.php" file as example. The web page must have extension .php and not .html.

I included webpagetemplate.php file that is an unsecured page template, the secured_template.php file that is accessible only to registered users and the admin_template.php file that is accessible only to users with the admin role. When your register yourself, you should set role to admin. You can do that in phpMyAdmin. Open username table, find your record and change role from user to admin. All the rest users will have role user and will not have access to admin pages. See how to use phpMyAdmn above.

I include style.css files to control web page design and layout and JavaScript files for user input validation.

Test your web site user registration. Create your account, login and password. Email with activation link will be sent to your user email. Open email and click the activation link. Your account will be activated. Log into your web site. Try to access pages with limited permissions before you login and after. Try to login as a regular user and as an admin.

If you cannot create database and usernames table or have any question, feel free to contact me by email:

You should be aware that even though your web site users use login and password to access certain web pages it does not mean that that pages are secured. The difference between secure and unsecure connection depends on what kind Hypertext Transfer Protocol is used.

There are HTTP and HTTPS transfer protocols. If web site use https transfer protocol it means that data, which is transferred between web server and client browser is encrypted.

If http protocol is used, it means that data is not encrypted and can be eavesdropped. However, you can use unsecure HTTP protocol with login and password for such web sites as message boards, social sites etc., and many others web site use HTTP. They have some kind of protection that is enough for them.

If you are not a bank, you can use HTTP protocol with login and password. You even can use unsecure HTTP for business site. For example, you may display your products or services on unsecure page, but when user needs to enter payment he or she is redirected to secured page. My website uses HTTP protocol. It is not secured, but I use PayPal secured page to accept payment.

Hosting company I use and recomend!

1. I use it for, and
40% off at FatCow!

Affiliate Disclosure: I may get comission, when you purchase products or services through links on my website.

My eBooks on

Comments (2)

Topic: User Authentication, User Registration Script. PHP
5/5 (1)
Many thanks for your personal sharing. We experience more than happy about that. You should also consider their finest game titles with our free currently to find the sense of exciting that brings.

8th December 2017 2:21am
Full StarFull StarFull StarFull StarFull Star
write my essay
Delightful work, I have gone by your site unexpectedly. Much thanks for having such an enlightening online journal! Rundown A debt of gratitude is in order for sharing such a fantastic post. It is extraordinary website for where we can discover numerous visitor online journals locales with full detail.
8th December 2017 2:20am
Page 1 of 1

Add Comment

* Required information
(never displayed)
Smile Sad Huh Laugh Mad Tongue Crying Grin Wink Scared Cool Sleep Blush Unsure Shocked
What is the day after Friday?
Enter answer:
Enter code:
Notify me of new comments via email.
Remember my form inputs on this computer.
I have read and understand the privacy policy. *
I have read and agree to the terms and conditions. *
Powered by Commentics