0
votes

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

1
Are you sure {{ URL('signup') }} is evaluating to what your expecting?cmac
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
I was using this {{ route('signup') }} but it didn't work so I tried the syntax you posted and no luckOoguro
Just put this "/signup" in your form action and see if it workscmac
no luck cmac I tried it a few timesOoguro

1 Answers

0
votes

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