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

Flex's avatar
Level 4

The GET method is not supported for this route. Supported methods: POST in Laravel 9 shared hosting

working with Laravel 9 and this is working fine in my localhost. but when i deploy it with shared hosting on hostgrator and click contact form it is encountered following error messages Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException The GET method is not supported for this route. Supported methods: POST. I have following contact form in the blade file

<div class="content">
@include('partials.alerts')
    <h1 class="heading">Contact Us</h1>
    
    
    <form method="post" action="{{url('form')}}#contact">
        {{method_field('POST')}}
            {{csrf_field()}}
            <div class="form">
  <div class="input-flex">
    <input type="text" name="name" placeholder="Name*" /><br><br>
    <span style="color:red">@error('name'){{$message}}@enderror</span>
    <input type="email" name="email" placeholder="E-mail*" /><br><br>
    <span style="color:red">@error('email'){{$message}}@enderror</span>
    <input type="tel" class="full-width" name="telephone" placeholder="Phone number*" /><br><br>
    <span style="color:red">@error('telephone'){{$message}}@enderror</span>
    <textarea cols="2" rows="2" class="full-width" name="message" placeholder="Message"></textarea>
   </div>
  <button  class="conbtn" type="submit">Submit</button>
</form>

and web.php

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

Route::post('form','App\Http\Controllers\UserController@store');

Route::get('/user/verify/{token}', 'App\Http\Controllers\UserController@verifyUser');

how could I fix this problem?

0 likes
8 replies
LaryAI's avatar
Level 58

The error message "The GET method is not supported for this route. Supported methods: POST" indicates that the route is only configured to accept POST requests, but a GET request was made instead. To fix this issue, change the form method from GET to POST:

<form method="post" action="{{url('form')}}#contact">
    {{csrf_field()}}
    <input type="hidden" name="_method" value="POST">
    <!-- rest of the form -->
</form>

Also, make sure that the route is defined as a POST route in your web.php file:

Route::post('form','App\Http\Controllers\UserController@store');
Tray2's avatar

Just a wild guess here, but remove the #contact from the action and use a named route instead like this

<form action="{{ route('books.store') }}" method="post">

And in your routes

Route::post('/books/store', BooksController@store)->name('books.store');
Snapey's avatar

What do you do at the end of the controller method? The error could be coming after the controller is method is processed, or as a result of validation error

Flex's avatar
Level 4

@Snapey My controller store function

 protected function store(Request $request)
    {
        //validate request
        $this->validate($request,[
            'name' => 'required|max:100',
            'email' => 'required|email',
            'telephone' => 'required',
        ]);

        $user = new User;

        $user->name = $request->input('name');
        $user->email = $request->input('email');
        $user->telephone = $request->input('telephone');
        $user->message = $request->input('message');
        
        $user->save();

        $verifyUser = VerifyUser::create([
            'user_id' => $user->id,
            'token' => Str::random(40)
        ]);

        Mail::to($user->email)->send(new VerifyMail($user));

       
       return redirect('#contact')->with('info', 'We sent you an activation code. Check your email and click on the link to verify');
    }
Snapey's avatar
Snapey
Best Answer
Level 122

@Flex your return redirect does not say which page to redirect to, only the anchor

Flex's avatar
Level 4

@Snapey very well is is working fine I change My return redirect as

return redirect('/#contact')->with('info', 'We sent you an activation code. Check your email and click on the link to verify');

Please or to participate in this conversation.