Step:1 Make a page.
resources/views/my_message.blade.php
<html lang="en"> | |
<head> | |
<title>How can use Flash message in laravel 5.8</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" > | |
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> | |
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> | |
</head> | |
<body> | |
<div class="container" style="margin-top: 50px"> | |
<div class="col-md-8 col-md-offset-2"> | |
<div class="panel panel-default"> | |
<div class="panel-heading">Login</div> | |
@if ($message = Session::get('success')) | |
<div class="alert alert-success alert-block"> | |
<button type="button" class="close" data-dismiss="alert">×</button> | |
<strong>{{ $message }}</strong> | |
</div> | |
@endif | |
@if ($message = Session::get('error')) | |
<div class="alert alert-danger alert-block"> | |
<button type="button" class="close" data-dismiss="alert">×</button> | |
<strong>{{ $message }}</strong> | |
</div> | |
@endif | |
@if ($message = Session::get('warning')) | |
<div class="alert alert-warning alert-block"> | |
<button type="button" class="close" data-dismiss="alert">×</button> | |
<strong>{{ $message }}</strong> | |
</div> | |
@endif | |
@if ($message = Session::get('info')) | |
<div class="alert alert-info alert-block"> | |
<button type="button" class="close" data-dismiss="alert">×</button> | |
<strong>{{ $message }}</strong> | |
</div> | |
@endif | |
@if ($errors->any()) | |
<div class="alert alert-danger"> | |
<button type="button" class="close" data-dismiss="alert">×</button> | |
Please check the form below for errors | |
</div> | |
@endif | |
<div class="panel-body"> | |
<form class="form-horizontal" method="POST" action="{{ route('my_message.post') }}"> | |
{{ csrf_field() }} | |
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> | |
<label for="email" class="col-md-4 control-label">E-Mail Address</label> | |
<div class="col-md-6"> | |
<input id="email" type="text" class="form-control" name="email" value="{{ old('email') }}"> | |
@if ($errors->has('email')) | |
<span class="help-block"> | |
<strong>{{ $errors->first('email') }}</strong> | |
</span> | |
@endif | |
</div> | |
</div> | |
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> | |
<label for="password" class="col-md-4 control-label">Password</label> | |
<div class="col-md-6"> | |
<input id="password" type="password" class="form-control" name="password"> | |
@if ($errors->has('password')) | |
<span class="help-block"> | |
<strong>{{ $errors->first('password') }}</strong> | |
</span> | |
@endif | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-md-8 col-md-offset-4"> | |
<button type="submit" class="btn btn-primary"> | |
Submit | |
</button> | |
</div> | |
</div> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> | |
Copy this code and paste in the my_massage.blade.php
Step:2 make a controller
php artisan make:controller MessageController

Step:3 Copy this code and paste in the MessageController.page
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
class MessageController extends Controller | |
{ | |
public function my_message(){ | |
return view('my_message'); | |
} | |
public function my_message_post(){ | |
request()->validate([ | |
'email' => 'required|email', | |
'password' => 'required', | |
]); | |
} | |
} |

Step:3 make a route function
Route::get('my_message', 'MessageController@my_message')->name('my_message'); | |
Route::post('my_message', 'MessageController@my_message_post')->name('my_message.post'); |
Step:4 php artisan serve

paste this code in your browser
http://127.0.0.1:8000/my_message




MotoShare.in is your go-to platform for adventure and exploration. Rent premium bikes for epic journeys or simple scooters for your daily errands—all with the MotoShare.in advantage of affordability and ease.