Home > Net >  Laravel : method is not supported for this route
Laravel : method is not supported for this route

Time:02-08

the error is : The GET method is not supported for this route. Supported methods: POST. although the website works on localhost but on the server doesnt work ?? any solutions


 protected function methodNotAllowed(array $others, $method)
    {
        throw new MethodNotAllowedHttpException(
            $others,
            sprintf(
                'The %s method is not supported for this route. Supported methods: %s.',
                $method,
                implode(', ', $others)
            )
        );
    }

layout

@extends('install.layout')

@section('content')
<div >
  <div >Login Details</div>
    <div >
       <div >
            @if ($errors->any())
                <div >
                    <a href="#"  data-dismiss="alert" aria-label="close">&times;</a>
                    @foreach ($errors->all() as $error)
                       <p>{{ $error }}</p>
                    @endforeach
                </div>
            @endif
            <form action="{{ url('install/store_user') }}" method="post" autocomplete="off">
                {{ csrf_field() }}
                <div >
                    <label>Name</label>
                    <input type="text"  name="name" value="{{ old('name') }}" required>             
                </div>
                
                <div >
                    <label>Email</label>
                    <input type="email"  name="email" value="{{ old('email') }}" required>  
                </div>
                
                <div >
                    <label>Password</label>
                    <input type="password"  name="password" required>
                </div>
                <button type="submit" >Next</button>
            </form>
       </div>
    </div>
</div>
@endsection


######################################################################################################################################################## Web Route

<?php
Route::post('install/store_user', 'Install\InstallController@store_user');
?>

installController

    public function store_user(Request $request)
    {
        $validator = Validator::make($request->all(), [ 
            'name' => 'required|string|max:191',
            'email' => 'required|string|email|max:191|unique:users',
            'password' => 'required|string|min:6',
        ]);
        
        if ($validator->fails()) {  
                return redirect()->back()
                            ->withErrors($validator)
                            ->withInput();          
        }
        
        $name = $request->name;
        $email = $request->email;
        $password = Hash::make($request->password);
        
        Installer::createUser($name, $email, $password);
        
        return redirect('install/system_settings');
    }

CodePudding user response:

In your form you may give post method but in route you may assign get method. Please cross check it.

CodePudding user response:

most likely it's because of your URL in the form change your form

from

<form action="{{ url('install/store_user') }}" method="post" autocomplete="off">

to

<form action="{{ url('install,store_user') }}" method="post" autocomplete="off">
  •  Tags:  
  • Related