I'm trying to use POST to let user log in with correct email/password. I keep getting this error
MethodNotAllowedHttpException at RouteCollection->methodNotAllowed(array('POST'))
web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
Route::get('/', function () {
return view('login');
});
Route::post("/login",[UserController::class,'login']);
UserController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserController extends Controller
{
//
function login(request $req)
{
return $req->input();
}
}
login.blade.php
@extends('master')
@section('content')
<div class="container custom-login">
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<form action="/login" method="POST">
<div class="form-group">
@csrf
<labe for="exampleInputEmail">Email address</label>
<input type="email" name="email" class="form-control" id="exampleInputEmail" placeholder="Email">
</div>
<div class="form-group">
<labe for="exampleInputPassword">Password</label>
<input type="password" name="password" class="form-control" id="exampleInputPassword" placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Login</button>
</form>
</div>
</div>
</div>
@endsection
I tried opening the login page but POST is having issues. I expected the login page to use POST to check credentials in my database.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire