Creat Laravel Login and Registration page with Form validation

Last updated Jan 17, 2022


An integral part of most web applications is the user authentication process using a register and login module. In this module, users can register using their credentials and log in with the correct credentials after registering. We'll create a Laravel login and registration page with form validation in this post.

How to create a Laravel Login and Registration page with Form validation

Laravel 8 has an integrated custom authentication system that allows users to log in, register and logout. Consequently, we will develop a custom login and registration system in Laravel.

Below are the steps for creating the login and registration page with form validation:

Step 1: You must first download and install Laravel into your project directory. To install Laravel, simply run the command below from your Windows command prompt:

composer create-project --prefer-dist laravel/laravel login_register

 

laravel-create-project

A new directory, laravelauth, will be created in your Xamp htdocs folder and Laravel files installed inside.

 

laravel-project-folder-structure

Step 2: After installing laravel, you need to create a MySQL database for storing user data.  Launch your PHPMyadmin  and create a database Laravel8

laravel-create-table

Step 3:  Now, you need to configure your database settings in your application.  Open your .env file and configure your DB_CONNECTION, DB_Host, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD.

laravel-env-file

Your application is now connected to the database.

Step 4:  Now, Open your App\Providers\ AppServiceProvider.php.  and  paste the code below:

 

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider

{

  • /**

     * Register any application services.

     *

     * @return void

     */

public function register()

{//

}

 

/**

     * Bootstrap any application services.

     *

     * @return void

    */

public function boot()

{

       Schema::defaultstringLength(191);

}

}

 

Step5: Now, in the command prompt, run the command composer require laravel/jetstream.

laravel-1

Step 6: Install livewire using the command php artisan Jetstream: install livewire.

laravel-2

  • Step 7: Now run npm install and npm run dev

Run npm install

 

laravel-3

Run npm run dev

laravel-server

Step 8: Migrate the database using the command php artisan migrate. Checking at the database, new tables are formed, and information is inserted.

laravel-login2

A new database tables with sample data is generated.

login-database-laravel

Step 9: We are done with creating a custom Laravel authentication.  Run the command php artisan serve to get the project URL.  All the three functionalities, login, user register, and form validation, functions well.

laravel-log1

Let’s check the three functionalities:

Login form:

 

laravel-login-form

Register Form

 

laravel-registration-form

Form Validation

 

laravel-registration-form

 

 

Download Source code

 

 


Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

404 Views

Subscribe For Daily Updates

Flutter Questions
Android Questions