rashedcs
rashedcs

Reputation: 3725

Trouble with routing in laravel?

I have tried to make a contact page. But the code did not work. Please help me to fix out it.......Route get contact work but when loading it shows error......

Form

              <form method="POST" action="{{ route('postcontact') }}" >

Route :

  Route::get('getcontact','ContactController@insertform');
  Route::post('postcontact','ContactController@insert');
Controller :
<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Model\user\product;
use DB;

class ContactController extends Controller
{   

    public function insertform()
    {   
         return view('frontend.contact.create');
    }

   public function insert() 
   {      
      dd("Check"); exit;
   }
}

enter image description here

Upvotes: 0

Views: 46

Answers (1)

akbar
akbar

Reputation: 773

You do not assign route name for your post routing . Try one of these solutions: 1.Try it in routing:

Route::post("/yoururl","controller@method")->name("postcontact");

2.Change your action in form tag:

<Form action="/yoururl" method="post">

By the way,dont forget {{csrf_field()}}.

Upvotes: 2

Related Questions