Home > Blockchain >  The POST method is not supported for this route. Supported methods: GET, HEAD
The POST method is not supported for this route. Supported methods: GET, HEAD

Time:12-16

I am getting this error on form submission: The POST method is not supported for this route. Supported methods: GET, HEAD. Here is the form code:

<form action="bid" method = "POST" >
    @csrf
    <h2>
        Your Bid
    </h2>
    <h4 style="font-size:15px;color:antiquewhite">Days</h4>
                                    <input type="number" name="days" placeholder=" Your Days to complete project" ><br />
                                    <h4 style="font-size:15px;color:antiquewhite">Cost</h4>
                                    <input type="number" name="cost" placeholder="Your bid cost in $ doller" ><br />
                                    <button  type="submit">Send</button>

</form>

and here is the Route code:

Route::post('bid','App\Http\Controllers\register@bid');

I have tried using php artisan route:cache

CodePudding user response:

The first thing, a recommendation, write your routes like this and give your route any name;

Route::post('bid','App\Http\Controllers\register@bid');

to

Route::post('bid',[\App\Http\Controllers\register::class, 'bid'])->name('uniqueRouteName');

And call this route with name;

<form action="{{ route('uniqueRouteName') }}" method = "POST" >
        @csrf
        <h2>
            Your Bid
        </h2>
        <h4 style="font-size:15px;color:antiquewhite">Days</h4>
        <input type="number" name="days" placeholder=" Your Days to complete project" ><br />
        <h4 style="font-size:15px;color:antiquewhite">Cost</h4>
        <input type="number" name="cost" placeholder="Your bid cost in $ doller" ><br />
        <button  type="submit">Send</button>
</form>

CodePudding user response:

<form action="/bid" method = "POST" > Tried different things but ultimately this solved my problem.

  • Related