I Have tried to create a login page in Laravel 5.6 it shows the following error
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
I have used the POST method for the routing but the server shows the same error screenshot of the same is added. enter image description here
The code of view
<body>
<div class="data-head">
{{ Form::open(array('url' => 'login')) }}
<p class="col-md-12">
<h5 class="login-head">Login</h5>
</p>
<p>
{{ $email_err }}
</p>
<p class="col-md-10 col-md-move">
{{ Form::label('email', 'E-Mail Address', array('class' => 'awesome')) }}
{{ Form::text('email','', array('placeholder' => '[email protected]', 'class' => 'form-control')) }}
</p>
<p class="col-md-10 col-md-move">
{{ Form::label('password', 'Password', array('class' => 'awesome')) }}
{{ Form::password('password', array('placeholder' => 'Password', 'class' => 'form-control')) }}
</p>
<p class="col-md-10 col-md-move">
<a href="forget" class="link-forget">Forget Password ? </a>
{{ Form::submit('Login', array('class' => 'btn btn-info')) }}
</p>
</div>
</body>
Route file:
Route::post('/', function () {
return view('welcome');
});
Route::post('register',function(){
return view('login');
});
Route::post('login', 'LoginController@loginProcess');
The controller code
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Hash;
class LoginController extends Controller
{
public function loginProcess(Request $request)
{
$email_err="";
$password_err="";
$pass="";
$email = $request->input('email');
$password = $request->input('password');
$pass=DB::table('login')->where('email', $email)->value('password');
if($pass=="")
{
$email_err="Non Registred User";
return view('login',['email_error' => $email_err]);
}
if(Hash::check($password,$pass))
{
echo "Login Successs";
}
else
{
$password_err="Invalid Password";
}
}
}
Thanks in advance
{{csrf_token()}}
in your form – rkj