i am working on a e-commerce website using laravel 8 for the first time i created a login and registration views, when i try registering first it flashed iccorrect email adresse in session error that is displayed in register.blade.php after fixing that it redirected me to an error page with this text :
The GET method is not supported for this route. Supported methods: POST. http://localhost:3000/create?_token=7vVwL33yaBmkmsJIKHl78XfzZNmk4vJDBG9qumhf&email=theoghmir.kodia%40laposte.net&name=HELLh&password=2223541
my route is acctually set to POST did i forget some thing ? here is my web.php
<?php use IlluminateSupportFacadesRoute; use AppHttpControllersauthController; Route::get('/', function () { return view('welcome'); }); Route::get('/auth', [authController::class, 'authpage']); Route::get('/auth/check', [authController::class, 'check'])->name('auth.check'); Route::get('/register', [authController::class, 'register']); Route::post('/create', [authController::class, 'create'])->name('auth.create'); Route::get('/logout', [authController::class, 'logout']);
here the register.blade.php
<form action="{{ route('auth.create')}}" methode="POST"> @if(Session::get('fail')) <div class="alert alert-danger">{{Session::get('fail')}}</div> @endif @if(Session::get('success')) <div class="alert alert-success">{{Session::get('success')}}</div> @endif @csrf <label>name :</label> <input type="text" class="form-control" name="name" placeholder=" name..." > <label>Email :</label> <input type="text" class="form-control" name="email" placeholder=" email..." value="{{old('email')}}"> <span class="text-danger"> @error ('email') {{$message}} @enderror</span><br> <label>Password :</label> <input type="password" class="form-control" name="password" placeholder="Mot de passe..."> <span class="text-danger"> @error ('password') {{$message}} @enderror</span><br> <button type="submit">S'inscrir</button> </form>
here is the auth controller with the methode create() :
namespace AppHttpControllers; use IlluminateHttpRequest; use AppModelsUser; use AppHttpControllershash; class authController extends Controller { public function authpage() { return view('login'); } public function register() { return view('register'); } public function create(Request $request) { $request->validate([ 'email'=>'required|email|unique:users', 'password'=>'required|min:5|max:12', ]); $user = new User ; $user -> name = $request->name; $user -> email = $request->email; $user -> password = $request->password; $query = $user->save(); if($query) { return back()->with('success',' vous êtes inscris avec succées ! ' ); }else{ return back()->with('fail',' il y as quelque chose qui cloche ! ' ); } }
Advertisement
Answer
You have an syntax error, it is not methode=
but method="POST"
<form action="{{ route('auth.create')}}" method="POST">