Magento 2 Development Workshop Learn More

User Registration with PHP and MySQL

14 lessons

User Registration Form

In this lesson, we are going to learn how to create an user registration form in a PHP file. The HTML registration form is later be used to submit data into the signup.php script.

Lesson Overview

In this lesson, we are going to learn:

  • How to create User Registration Form
  • We will review required form fields to register a user

User Registration

In order to create a user registration in a PHP application, we have to create an HTML form. The form is responsible for providing allowing a user to submit required for the registration information. The information that we are going to process is the following:

  • Username
  • Email
  • Password
  • Confirm Password

Both Username and Password are going to be used by a user to login into the application. An email is used to send the confirmation email to the user so the registration can be confirmed when the user hits the confirmation link.

Source Code

This is our initial HTML markup for the register.php script:

<html lang="en">
<head>
  <title>User Registration</title>
</head>
<body>
  <h1>Register</h1>
</body>
</html>

After the lesson you should have the register.php script as follow:

<html lang="en">
<head>
  <title>User Registration</title>
</head>
<body>
  <h1>Register</h1>
    <form action="signup.php" method="POST">
      Username: <input type="text" name="username" /><br />
      Email: <input type="text" name="email" /><br />
      Password: <input type="text" name="password" /><br />
      Confirm password: <input type="text" name="password_confirm" /><br />
      <input type="submit" value="Register" />
    </form>
</body>
</html>

As a result, in the browser we should see something similar to the below Registration form.

User Registration Form Result

In the next lesson, we are going to create the signup.php script in order to process the submitted user data from the user registration form, that we created in the current lesson.