This tutorial will teach how to make a Login and Registration.it is an very important stuff make an custom Login and Registration forms. this tutorials will help you to learn every thing.
composer create-project laravel/laravel project-app
Create the database on the mysql.what the database you have created that particular name you have to give on .env file.
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=dbproject DB_USERNAME=root DB_PASSWORD=
i have created the database which is dbproject. i gave the name on the .env file.
After that you have to make table migration.
In order to make a login registration we already have a model User. you can see inside the Models folder. let update it so lets run the command
php artisan migrate
create the routes in order to manage the url requests
<?php use Illuminate\Support\Facades\Route; use App\Http\Controllers\RegisterController; use App\Http\Controllers\LoginController; Route::get('/', [RegisterController::class, 'create']); Route::post('/register', [RegisterController::class, 'store'])->name('register'); Route::get('/login', [LoginController::class, 'index']); Route::post('/check', [LoginController::class, 'check'])->name('check');
Create Controller
<?php namespace App\Http\Controllers; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Hash; class RegisterController extends Controller { public function create() { return view('contact.create'); } public function store(Request $request) { $input = $request->all(); User::create([ 'name' => $input['name'], 'email' => $input['email'], 'password' => Hash::make($input['password']) ]); return view('contact.thanks'); } }
Controller return to view.
so let go the folder Resources inside the Resources folder we have to create inside the views folder create Contact folder. inside the folder have to create two different views create.blade.php and thanks.blade.php.
@extends('layout') @section('content') <div class="card"> <div class="card-header">Register Form</div> <div class="card-body"> <form action= "{{ route('register') }}" method="post"> {!! csrf_field() !!} <label>First Name</label> <input type="text" name="name" id="name" class ="form-control"> </br> <label>Email</label> <input type="email" name="email" id="email" class ="form-control"> </br> <label>Password</label> <input type="password" name="password" id="password" class ="form-control"> </br> <input type="submit" value="Save" class="btn btn-success"> </form> </div> </div> @stop
thanks.blade.php
@extends('layout') @section('content') <div class="card"> <div class="card-header">Contact Form</div> <div class="card-body"> <h2> Thanks You !!!!!!! </h2> </div> </div> @stop
Create Login Controller
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Hash; class LoginController extends Controller { public function index() { return view('login.index'); } public function check(Request $request) { $credentials = $request->validate([ 'email' => ['required', 'email'], 'password' => ['required'], ]); if (Auth::attempt($credentials)) { return view('login.home'); } return "<h2>Username or Password Invalid!</h2>"; } }
Login view Files
index.blade.php
@extends('layout') @section('content') <div class="card"> <div class="card-header">Login Form</div> <div class="card-body"> <form action= "{{ route('check') }}" method="post"> {!! csrf_field() !!} <label>Email</label> <input type="email" name="email" id="email" class ="form-control"> </br> <label>Password</label> <input type="password" name="password" id="password" class ="form-control"> </br> <input type="submit" value="Login" class="btn btn-success"> </form> </div> </div> @stop
home.blade.php
@extends('layout') @section('content') <div class="card"> <div class="card-header">Contact Form</div> <div class="card-body"> <h2> Welcome !!!!!! </h2> </div> </div> @stop
In this tutorial will teach Laravel 11 Api MVC with Repository Pattern Crud Application step…
In this tutorial will teach Laravel 11 CRUD Application step by step. Laravel 11 CRUD…
in this tutorials we will be talk about how to make a times table in…
In this tutorials will teach How to add two numbers in Laravel 10. (more…)
In this tutorial, we will teach the process of building a full-stack application using Node.js,…
In this tutorial, we will explin you through the process of building a Hospital Management…