Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

brakkar's avatar
array:4 [▼
  "_token" => "IIZcvyxqKwI7WrQ6YKXEqq6NAszLNIps7UvEjAYZ"
  "username" => null
  "email" => null
  "password" => null
]
Jaytee's avatar

Yeah so the form isn't submitting. Got any Javascript preventing it from submitting?

Also, what other routes do you have ? On top of that, I noticed that your 'user' is not capitalised on your routes, wanna make them capitalised please and see if that solves it:

Users\UsersController@store etc

brakkar's avatar

Here are all the routes, with directory capitalized. I haven't touched or created any js:

Route::get( '/', 'base\BaseController@index' )->name('home');


#------------------------------------------------------------------------------------
# Users
#------------------------------------------------------------------------------------
Route::get('/user/login', 'Users\UsersController@login');

Route::get( '/user/register', 'Users\UsersController@create' )->name( 'registerget' );
Route::post( '/user/register', 'Users\UsersController@store' )->name( 'registerpost' );
Jaytee's avatar

Alright i see you've given your routes a name. Try that in the action of the form. It's worth a shot.

<form method="POST" action="{{ route('registerpost') }}">
    <!-- Add your fields here -->
    <input type="submit" value="Register"> 
</form>
brakkar's avatar

A note: when the form validates, it correctly pass value to create the record in the database. So the problem seems specificaly with invalidation.

For some reason, your latest example IS working !! Thank you so much.

SaeedPrez's avatar

@Jaytee it shouldn't matter if he's using the route helper or not, because his store() method is being called upon submitting the form..

@brakkar Change your form method to GET and post the URL in your browser after you submit the form..

<form method="GET" action="/user/register">

You should get something like

http://localhost/user/register?name=foo&username=bar ...

Edit: I'm thinking maybe it was some cache problem.. should perhaps have tried php artisan view:clear

1 like
Jaytee's avatar

@SaeedPrez Yeah I know, was just trying other options.

So i'm guessing it's either to do with the method not being uppercase, a button of type submit being used instead of an input or the browser was just being funny?

I researched and even though i found something from 8 years ago, one of them was the browser playing up.

brakkar's avatar

Guys, it's all working now. I restarted the entire computer and local servers. Seems there was something messing up upon form submission with clearing the fields. Sorry I should have done that much much earlier computer is being one since several days.

Jaytee's avatar
Jaytee
Best Answer
Level 39

@SaeedPrez Not sure if you remember but i raised a thread the other day where i was having cache problems with Chrome. That might make sense. I tried Canary and same issue so perhaps it's chrome (if that's what OP is using)

3 likes
khaledSMQ's avatar

can you do this please


<?php
// put this class in your  App\Http\Requests folder and make sure the namespace match your namespace
namespace App\Http\Requests;

use App\User;
use Illuminate\Foundation\Http\FormRequest;

class UserCreateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
           'username' => 'required|min:2',
            'email' => 'required|email',
            'password' => 'required',
        ];
    }
}


public function store(\App\Http\Requests\UserCreateRequest $request)
    {
         
        # Create
        $user = $this->create($request->all()))
        # Authenticate
        //auth()->login($user);

        # redirect
        return redirect()->home();
    }


protected function create(array $data)
    {
        return User::create([
            'name' => $data['username'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']), // always make sure not plain password in your database
        ]);
    }


1 like
SaeedPrez's avatar

@Jaytee I use <button type="submit"> myself, and lower/uppercase shouldn't matter either. Only thing I can think of now is cache..

1 like
brakkar's avatar

Khaled, thanks a lot for the code. Got it working. What an amazing support group guys.

Jaytee's avatar

@SaeedPrez Yeah I copied OP's snippet and it worked for me. So I guess we can say it's Chrome. I'm still having Caching issues, you raised the caching issue and OP said he was using Chrome.......

1 like
SaeedPrez's avatar

@Jaytee damn Google, they can search billions of websites in 0.0000001s but can't fix a damn cache issue ☺

1 like
leodesign's avatar

call validation like this instead

$request->validate([
     'name' => 'required'
      //..
 ]);

//...
1 like
Previous

Please or to participate in this conversation.