laravel validation doesn’t work - development

laravel validation doesn’t work

I am taking a laravel course an in order to follow the course I have to fix this issue, I checked everything, and apparently, everything is the same as the guy shows me. But the difference is that his validation works but not mine. It has to redirect me to the register_form when the validation is invalid but it doesn’t.

Route

Route::get('/', function(){
    return view('welcome');
});

Route::get('/register', 'HomeController@register_form');

Route::post('/register', 'HomeController@register');

Controller

namespace CoolBlogHttpControllers;

use IlluminateHttpRequest;

class HomeController extends Controller {

    public function register_form(){
        return view('register');
    }

    public function register(Request $request) {
        $this->validate($request, [
            'username' => 'min:5|max:30',
            'email' => 'email',
            'pass' => 'min:5',
            'pass2' => 'same:pass'
        ]);
    }
}

Html Page

@extends('layout.default')

@section('title', 'Registration')

@section('content')
    <form method="post" action="/register" >
        
        Name: <input type="text" name="username"><br>
        E-mail: <input type="text" name="email"><br>
        Password: <input type="password" name="pass2"><br>
        Re-Password: <input type="password" name="pass2"><br>
        <input type="submit" value="Register">
    </form>

@endsection



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-validation-doesnt-work/
via Lzo Media

Comments

Popular posts from this blog

ng-include of inline SVG does not display gradient except in Chrome

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development

ng-show doesn’t work correct with value boolean