0

Ok so trying to submit a form in Laravel, but keep getting this issu

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message

I check all my code to see what could be the problem, I even tried the command php artisan route:list and signup route shows up

welcome.blade.php
  <form action="{{ URL('signup') }}" method="post">
       <div class="form-group">
         <label for="email">You'r E-Mail</label>
           <input class="form-control" type="text" name="email" 
             id="email">
            </div>
            <div class="form-group">
            <label for="first_name">You'r First Name</label>
            <input class="form-control" type="text" 
             name="first_name" id="first_name">
            </div>
            <div class="form-group">
            <label for="password">You'r Password</label>
            <input class="form-control" type="password" 
              name="password" id="password">
            </div>
            <button type="submit" class="btn btn- 
              primary">Submit</button>
          <input type="hidden" name="_token" value=" 
            {{Session::token() }}">
        </form>

routes/web.php

 Route::group(['middleware' => ['web']],function(){

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

     Route::post('/signup',[
         'uses'=>'UserController@postSignUp',
         'as'=>'signup'
      ]);
     });

Controllers/UserController.php

  <?php
  namespace App\Http\Controllers;
   use Illuminate\Http\Request;

  class UserController extends Controller 
  {
      public function postSignUp(Request $request)
      {
         $email = $request['email'];
         $first_name = $request['first_name'];
         $password = bcrypt($request['password']);
         $user = new User();
         $user->email = $email;
         $user->first_name = $first_name;
         $user->password = $password;
         $user->save();
      }
  public function postSignIn(Request $request)
  {

  }
}

After pressing submit button it should add to my xampp database I have running locally

Ooguro
  • 121
  • 2
  • 14
  • Are you sure {{ URL('signup') }} is evaluating to what your expecting? – cmac Feb 14 '19 at 19:31
  • Usually when this happens it's cause someone is post to a route registered with get instead of post, but it looks like yours is right "Route::post('/signup',[......" – cmac Feb 14 '19 at 19:32
  • I was using this {{ route('signup') }} but it didn't work so I tried the syntax you posted and no luck – Ooguro Feb 14 '19 at 19:32
  • Just put this "/signup" in your form action and see if it works – cmac Feb 14 '19 at 19:33
  • no luck cmac I tried it a few times – Ooguro Feb 14 '19 at 19:36
  • change it to get and see if you can get to it – cmac Feb 14 '19 at 19:42
  • Route::get('/signup',[... and go to that url in your browser – cmac Feb 14 '19 at 19:43
  • Can you get to the route using "get" request? – cmac Feb 14 '19 at 19:45
  • Ok I think there was an issue with naming of a variable, but know I think there is a new issue with server connection because Im getting this error "SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: insert into `users` (`email`, `first_name`, `password`, `updated_at`, `created_at`) values (aginem7078@gmail.com, asd, $2y$10$PcctS/C7fEKy/FpRrs/Qs..PFSmm6FPVgVsfil8oY5l9Ex3so/Re6, 2019-02-14 20:51:34, 2019-02-14 20:51:34)) ◀" I may just open a new question for this – Ooguro Feb 14 '19 at 20:52
  • This might help - https://stackoverflow.com/questions/50547724/how-to-resolve-the-error-sql-authentication-method-unknown-in-laravel-mysql – cmac Feb 14 '19 at 20:54
  • Can you include the stack trace and the output of `route:list`? – Travis Britz Feb 14 '19 at 23:16
  • That link solved it! sorry for the late notice – Ooguro Feb 21 '19 at 03:47

1 Answers1

0

MethodNotAllowedHttpException was do to the way I setup my server in XAMAPP and my routes. Solves it by How to resolve the error: SQL authentication method unknown in Laravel-MySql

Ooguro
  • 121
  • 2
  • 14