Login and Registration from Scratch with PHP and MySQL

Create a PHP login system including user sign-up, login, "remember me", password reset and user administration.
4.6 (53 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
999 students enrolled
$20
Take This Course
  • Lectures 36
  • Contents Video: 2 hours
    Other: 2 mins
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 10/2012 English

Course Description

Do you already know PHP and you're developing a website that needs user registration and login? By taking this course you'll learn how to develop a system from scratch where users can sign-up for a new account, login, and be provided with personalised content.

This course will teach you how to add the following features to your PHP website or web application:

  • User sign-up, including account activation by email
  • Login and logout
  • Protecting content for logged-in users only
  • "Remember me" functionality: remember the login even after closing the browser
  • Secure password reset: let the users reset their own passwords when they forget them
  • User administration: create, view, edit and delete users.


Additional lectures include improving the usability of the site with new HTML5 and JavaScript techniques.

Taught by experienced web application developer and online educator Dave Hollingworth, this course takes you in easy steps through the entire process of creating a website that includes user authentication. This course will take you step by step through the project until all the principles have been covered.

All the source code is included with the lectures, with clear comments in the code and all the guidance you need to create your own user authentication system.

This popular course has been completely rewritten and re-published in April 2015, replacing every lecture and adding over 20 brand new ones, with improved, more secure source code, and an entirely new user administration area.

What are the requirements?

  • You should be familiar with using PHP and MySQL to create a database driven web page
  • Basic knowledge of how to use PHP classes

What am I going to get from this course?

  • Create a website where users can sign-up for a new account
  • Let users login and logout, providing them with personalised content
  • Give users the option to remember their login, even after closing the browser
  • Let users securely reset their own password if they forget it
  • Require users to confirm their email address before they can login
  • Administer registered users with a user administration backend
  • Apply advanced techniques using HTML5 and JavaScript to improve usability and performance

What is the target audience?

  • This programming course is meant for people who are developing a website that need to have users sign-up and login so they can be provided with personalised, private content. All aspects of a creating a user login system are covered, from basic to advanced.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Introduction: set up the project structure and configure the database
03:26

Get an overview of what you're going to learn, how the project is structured, and start with first code for building your site.

The code shown in the video is attached and available to download in the resources section.

1 page

How to get the best out of the course by using the source code.

03:48

Use PHP class autoloading to make your code easier to write and maintain.

The code changes shown in the video are attached and available to download in the resources section.

03:14

Create the users table in the database and add the a configuration class to the code.

The code changes shown in the video are attached and available to download in the resources section, along with the MySQL database schema for creating the users table.

2 questions

Test your knowledge of PHP class autoloading.

Section 2: New user signup: create new users in the database
04:18

Why it's important to store passwords securely and how to do it easily.

The code changes shown in the video are attached and available to download in the resources section.

Article

Starting from version 5.5, PHP now includes functions for password hashing. So if you are using PHP 5.5 or later, you can use those instead of the PHPass library.

03:21

Create a page where the user can register a new account on your site.

The code changes shown in the video are attached and available to download in the resources section.

04:14

Validate the signup data before it's saved in the database, getting the user to make changes and submit the form again if anything is invalid.

The code changes shown in the video are attached and available to download in the resources section.

3 questions

Test your knowledge of the proper way to store passwords securely.

Section 3: Log users in and out, and remember and require login
02:08

How to remember state between pages using PHP sessions.

The code changes shown in the video are attached and available to download in the resources section.

05:55

Create a login page and let the user identify themselves by logging in.

The code changes shown in the video are attached and available to download in the resources section.

01:54

Let a user logout from your site, destroying the session.

The code changes shown in the video are attached and available to download in the resources section.

03:21

Restrict whole pages or parts of a page to logged-in users only.

The code changes shown in the video are attached and available to download in the resources section.

01:43

Restrict whole pages or parts of a page to anonymous (i.e. those that haven't logged in) users only.

The code changes shown in the video are attached and available to download in the resources section.

06:54

Add the option to remember the user's login even after they've closed the browser. Enable this functionality across multiple devices (PC, mobile etc.) for the same user.

The code changes shown in the video are attached and available to download in the resources section, along with the MySQL database schema for creating the remembered_logins table.

02:09

See the remember me functionality, developed in the previous video, in action.

04:37

Forget the remembered login when the user explicitly logs out, and clean up any expired remember tokens that have been left in the database.

The code changes shown in the video are attached and available to download in the resources section.

3 questions

Test your knowledge of the login and remember me functionality.

Section 4: Reset forgotten passwords and activate new accounts before allowing login
02:28

For password resets and account authentication, we'll need to send registered users an email from PHP. Add a class to send emails from code in a very simple way.

The code changes shown in the video are attached and available to download in the resources section.

05:25

Users will forget their passwords - provide a secure way for them to reset their own password without needing an administrator.

The code changes shown in the video are attached and available to download in the resources section, along with the MySQL database schema for adding the password reset fields to the users table.

01:31

See the password reset functionality, developed in the previous video, in action.

04:42

Require a newly registered user to confirm their email address before allowing them to login, by sending them an email containing a link that contains a unique token.

The code changes shown in the video are attached and available to download in the resources section, along with the MySQL database schema for adding the account activation fields to the users table.

02:08

See the account activation functionality, developed in the previous video, in action.

3 questions

Test your knowledge of password reset and account activation functionality.

Section 5: User administration: view, edit, create and delete registered users
02:57

Add an administrator role to the users table, so you can identify which users can access the administration area, and add a link to the administration area to the main site navigation.

The code changes shown in the video are attached and available to download in the resources section, along with the MySQL database schema for adding the administrator role field to the users table.

04:34

Add the admin area to the code and start with a paginated list of all the users in the database. Restrict access to this page to administrators only, denying access to those users who don't have the administrator role.

The code changes shown in the video are attached and available to download in the resources section.

01:57

Show all the data for a single user in the database, restricted to administrator users only.

The code changes shown in the video are attached and available to download in the resources section.

05:17

Edit a single user's data, restricted to administrator users only.

The code changes shown in the video are attached and available to download in the resources section.

02:00

Delete a single user record from the database, restricted to administrator users only.

The code changes shown in the video are attached and available to download in the resources section.

04:58

Most users will create accounts themselves using the signup form, however it might be necessary for an administrator to create a user. Add a single user record to the database, restricted to administrator users only.

The code changes shown in the video are attached and available to download in the resources section.

04:35

As it stands, an administrator user could edit their own user and remove the administrator role, or even worse, delete their own user, thereby locking themselves out. Prevent this by disabling the controls that would allow an administrator to do this.

The code changes shown in the video are attached and available to download in the resources section.

01:36

At this stage we have a fully functional user authentication system, which includes the following features:

  • Signup, with account activation by email
  • Login and logout
  • Protected content
  • Remember me (across multiple devices)
  • Password reset
  • User administration
There are some alternatives if you don't want to code all this yourself, which we'll see here, and we'll also look at what's coming up in the next lectures.
3 questions

Test your knowledge of the user administration area.

Section 6: Usability, functionality and design improvements
03:54

Speed up the process of signing up to your site by adding client-side validation to the signup form using HTML5 form validation methods.

The code changes shown in the video are attached and available to download in the resources section.

02:18

Add JavaScript and the jQuery library to your site, optimising for faster site performance.

The code changes shown in the video are attached and available to download in the resources section.

04:52

Add JavaScript validation to the signup form, enabling it for non-HTML5 browsers, and also allowing us to do remote validation using AJAX.

The code changes shown in the video are attached and available to download in the resources section.

03:17

Now that we have client side validation on the signup form, we can add it to the similar form for creating or editing a user in the user admin area.

The code changes shown in the video are attached and available to download in the resources section.

02:45

Make filling in forms easier by avoiding the additional click required after opening a page with a form, and add client-side validation to the password reset form.

The code changes shown in the video are attached and available to download in the resources section.

04:05

Currently our application is functional, but doesn't look too great. Use a front-end framework and add a CSS file to our application to make it look great, and work in every browser, in no time.

The code changes shown in the video are attached and available to download in the resources section.

Article

Full source code that includes all the incremental changes we've made throughout the course.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Hi, I'm Dave Hollingworth. I'm an IT trainer and web application developer. I've been programming for over twenty-five years, and teaching IT since 1999.

I've developed enterprise-level applications on platforms ranging from mainframes to mobiles: from my first web application, a quotes system created for a major insurance company back in 1999 - the first of its type in the sector - to interactive learning management systems for online language learning.

I've taught courses ranging from basic use of email to advanced web application development, both online and in-person. I've been teaching on Udemy since 2012.

I'm passionate about technology, and love teaching it! I believe it's possible to explain even the most complex subjects in a simple, straightforward way that doesn't confuse the student.

I look forward to welcoming you onto one of my courses!

Ready to start learning?
Take This Course