Reputation: 1494
I wish to send a query like string to a POST request, this string is in a variable called $info
$info = firstname=testing123&lastname=testing123&[email protected]&number=123
So my routes will be like this
Route::post('/action/{date}/{time}/{info}', 'Action@confirm');
And my form like this
<form action="/confirmation/{{$date}}/{{$time}}/{{$info}}" method="POST">
{{ csrf_field() }}
<input type="text" name="action" required>
<button>Submit</button>
</form>
I cannot pass the $info
variable, I get a No such file or directory
error.
How can I pass a query like string to a POST request using routes?
Upvotes: 0
Views: 5265
Reputation: 6348
Query parameters do not need to be defined in the route. So you can remove the info
parameter from the route definition.
Route::post('/action/{date}/{time}', 'Action@confirm');
Then add the query string to your action
on the form
<form action="/confirmation/{{$date}}/{{$time}}?{{$info}}" method="POST">
...
</form>
And in the controller you can access the data the same way you would any other parameter
$firstname= $request->get('firstname');
Alternatively I would consider a different way of transmitting that data. From what you've provided it looks like might be more appropriate to store that data in the session then retrieve it from the session in the Action@confirm
method.
Upvotes: 3