mardi 11 octobre 2016

MethodNotAllowedHttpException in RouteCollection.php in laravel 5.1

This is the code and I am working on form and when I submit the form, it shows this error:

MethodNotAllowedHttpException in RouteCollection.php line 218

Here is my code:

UserController.php

    <?php

namespace App\Http\Controllers;

use App\User;
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();
        return redirect()->back();

    }


}

routes.php

<?php


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

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

welcome.blade.php

@extends('layouts.master')

@section('title')
    Welcome!
@endsection

@section('content')
    <div class="row">
        <div class="col-md-6">
            <h3>Sign Up</h3>
            <form action="" mathod="post">
                <div class="form-group">
                   <label for="email">Email</label> 
                  <input type="email" class="form-control" name="email">
                </div>

                <div class="form-group">
                   <label for="first_name">Your First Name</label>  
                  <input type="text" class="form-control" name="first_name">
                </div>

                <div class="form-group">
                   <label for="password">Password</label>   
                  <input type="password" class="form-control" name="password">
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
                <input type="hidden" name="_token" value="">
            </form>

        </div>



    </div>
@endsection

Please note that I am working on laravel 5.1 & I am a beginner. Can you please help me to solve the problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire