0

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" class="form-input"><br />
                                    <h4 style="font-size:15px;color:antiquewhite">Cost</h4>
                                    <input type="number" name="cost" placeholder="Your bid cost in $ doller" class="form-input"><br />
                                    <button class="btnn-U" 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

2 Answers2

0

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" class="form-input"><br />
        <h4 style="font-size:15px;color:antiquewhite">Cost</h4>
        <input type="number" name="cost" placeholder="Your bid cost in $ doller" class="form-input"><br />
        <button class="btnn-U" type="submit">Send</button>
</form>
Talha Can
  • 111
  • 8
  • Please add some explanation to your answer such that others can learn from it – Nico Haase Dec 16 '22 at 08:18
  • @talha This made the problem even worse. ``` Route [projectBid] not defined.``` –  Dec 16 '22 at 08:37
  • @RehmanAli did you add the route name to the route and did you run `php artisan route:clear` ? This is the correct solution. – Gert B. Dec 16 '22 at 11:34
0

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