When I save the form data to database using laravel it works fine. I used the reference from http://www.studentstutorial.com/laravel/insert-data-laravel.php to store the data to the database. But when I directly enter the url localhost:8000/create manually it throws exception.
Asked
Active
Viewed 204 times
0
-
11. What is the exception? 2. Where is the code? – BenM Jul 17 '18 at 16:38
-
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException – Devraj Jul 17 '18 at 16:41
-
It's fairly self-explanatory then, you haven't enabled the GET method on your route. – BenM Jul 17 '18 at 16:44
-
I already given a link of my code. I used the same code to insert data as given in this url - http://www.studentstutorial.com/laravel/insert-data-laravel.php – Devraj Jul 17 '18 at 16:48
-
when you call inbuit create function it is POST not GET – freelancer Jul 17 '18 at 16:49
-
1That tutorial is teaching really horrible Laravel practices. You should strongly consider something like https://laracasts.com/ instead. – ceejayoz Jul 17 '18 at 16:56
1 Answers
1
As your route is /create
, most probably its a "POST" route and the code at the given link shows that this route is POST method (as expected). POST routes can't open directly in browser, only GET routes can.
Routes given at the link:
Route::get('insert','StudInsertController@insertform');
Route::post('create','StudInsertController@insert');
You can test 1st route i.e. localhost:8000/insert
as its a GET route. 2nd route is POST, it can't be tested directly in browser. Test your post routes in API testing tools like "Postman".

TalESid
- 2,304
- 1
- 20
- 41
-
Yes you are right. But when any one will enter url /create then any one can see the exception that i don't want. It should show page not found 404 error page. I am totally new in Laravel so I confused how to do it... Thanks in advance... – Devraj Jul 17 '18 at 16:59
-
1Use custom erroor pages: **https://laravel.com/docs/5.6/errors#custom-http-error-pages** – TalESid Jul 17 '18 at 17:05
-