Reputation: 13434
I have a script code which will redirect to
http://localhost:8080/generated/sample/ + $('form.wpcf7-form').serialize();
and a sample generated url of that is
http://localhost:8080/generated/sample/_wpcf7=222&_wpcf7_version=4.5.1&_wpcf7_locale=en_US&_wpcf7_unit_tag=wpcf7-f222-p37-o1&_wpnonce=35162dc550&your-name=Robert+Soriano&your-email=sorianorobertc%40gmail.com&mobile-number=39174535417
The serialized value is from the Contact Form 7
plugin of WordPress.
In my slim route I have
<?php
// Routes
$app->get('/{name}', function ($request, $response, $args) {
// Sample log message
$this->logger->info("Slim-Skeleton '/' route");
// Render index view
return $this->renderer->render($response, 'index.phtml', $args);
});
$app->get('/generated/sample/', function ($request, $response, $args) {
return $args['your-email'];
// How to access different parameters here?
});
And what I get is this
It's like the first route is working for that but not the route that I want.
How can I access those parameters like the name, email, and all of it in my route?
Any help would be much appreciated.
Upvotes: 3
Views: 4000
Reputation: 20387
You can access query string parameters with $request->getQueryParams()
. Ie. something like
$params = $request->getQueryParams();
$email = $params["your-email"];
Or shorter version.
$email = $request->getQueryParam("your-email");
Upvotes: 8