I have a form that sends a get request to a /player/
route. When I click the submit button, the URL looks something like this:
https://examle.com/player?username=johndoe
I want the URL to look like this:
https://examle.com/player/johndoe
The username will then be passed as a parameter to a controller method:
public function player(string $username)
{
}
Is it possible to do this?
Thanks
2
Answers
Just create a simple route for it to accept username
The use the url to that accept username
I think this is basic, you can read on https://laravel.com/docs/10.x/routing#parameters-and-dependency-injection
If you need get, you can use other url, then redirect to the player location using same route() function. I assume that you want to submit data, so I put post as example
It’s not the way that HTML form operates. You can consider using jquery like below:
In web.php
In view: