Muonwar
Muonwar

Reputation: 11

PHP how to pass URL parameters to create a new URL

Very newbie question: setting up a Meraki wireless EXCAP walled garden, and will have users land on a terms-of-service.php (simple checkbox)... upon submission, will land on page with other info THEN need to pass to open web. Need to grab first URL, save it, pass to page2.php, and then out to web.

Meraki's example of incoming URL (when user attempts to access wireless):

http://MyCompany.com/MerakiSplashPage/?base_grant_url=https://example.meraki.com/splash/grant&user_continue_url=http://www.google.com&node_id=222222&gateway_id=222222&client_ip=10.222.222.222

Then "When you are ready to grant access to the user, send the user to GET['base_grant_url'] + "?continue_url=" + GET['user_continue_url']. In the case of the example above, this URL would be:

https://example.meraki.com/splash/grant?continue_url=http://www.google.com 

Going in circles on how to do this, any suggestions would be much appreciated.

Upvotes: 1

Views: 2151

Answers (2)

Babiker
Babiker

Reputation: 18808

Your final URL would be:

$_GET['base_grant_url']."?".$_GET['user_continue_url'];

Upvotes: 0

Gumbo
Gumbo

Reputation: 655619

Use rawurlencode to encode the value properly:

'http://MyCompany.com/MerakiSplashPage/?base_grant_url='.rawurlencode('https://example.meraki.com/splash/grant&user_continue_url=http://www.google.com').'&node_id=222222&gateway_id=222222&client_ip=10.222.222.222'

You can also use http_build_query to build the query automatically:

$query = array(
    'base_grant_url' => 'https://example.meraki.com/splash/grant&user_continue_url=http://www.google.com',
    'node_id' => '222222',
    'gateway_id' => '222222',
    'client_ip' => '10.222.222.222'
);
'http://MyCompany.com/MerakiSplashPage/?'.http_build_query($query)

Upvotes: 3

Related Questions