In the below snippet, I have an html form in my example page with the form's action attribute set to exampleController URI in my Routes as follows:
htmlPage.blade.php
<form action="/exampleController" method="POST">
// rest of form stuff goes here
</form>
@if(isset($result))
<table>
<td></td>
</table>
@endif
Web.php
Route::post('/exampleController', 'PageController@processData');
Controller.php
public function processData(Request $request)
{
$result = $request['htmlInputData'];
return view('htmlPage')->with(compact('result');
}
Everything is fine from here and data is being processed and displayed correctly on the page but I was wondering why the URL address the controller returned for the $result
variable is mydomain.com/exampleController
and not mydomain.com/htmlPage
which is the html page responsible for displaying the results of the operation.
Also, since the resulting URL address is mydomain.com/exampleController
(which is not what I expected), its returning the following error when manually refreshed:
MethodNotAllowedHttpException in RouteCollection.php line 233:
Can somebody please enlighten me what did I missed? thanks in advance.
via anagnam