I have created a simple post scheme, that would suppose to send input value to a function which has $request variable in a controller named about
When I run, I type "1234" into input box and click the button, It appears
http://127.0.0.1:8000/admin/about?_token=okqx4sLozgeA3W21nmCnKg5F7oqPqzm6OGpb8nSe&test=1234
in the browser address line, not doing anything about the function in controller, and seems to stay at the same page where the form is.
Does anyone have an idea about what the solution could be?
blade:
<form action="{{route('admin.about-post')}}" method="post">
@csrf
<input type="text" name="test">
<button type="submit" class="btn btn-primary">Save</button>
</form>
route:
Route::post('about-post', 'App\Http\Controllers\back\about@editPost')->name('admin.about-post');
controller:
class about extends Controller
{
public function editPost(Request $request){
dd($request); // To test, I should get some results here.
return redirect()->route('admin.about');
}
}
My Answer:
in the input value and click submit, but the page just refreshes and stays on the same page without any changes.
Here is my form code in my blade file:
html
And here is my controller code:
php
public function about(Request $request)
{
$inputValue = $request->input('input_value');
dd($inputValue);
}
Make sure that your route is defined correctly in your web.php file:
php
Route::post('/about', 'AboutController@about')->name('about');
If you are still facing the issue, try checking your network tab in the browser's developer tools to see if the form is actually submitting the data to the server. Also, make sure that your form is not being intercepted by any JavaScript code that might prevent it from submitting properly.
Rate this post
4 of 5 based on 4218 votesComments