-1

I am trying to get all the GET parameters, but I am not able to get them. Array is empty. The same I tried in a different server where it is working without any issue. Can anyone please help in solving this. I am wondering where could be the problem ?

http://example.com/test.php?utm_source=google&utm_medium=email&utm_campaign=X&utm_content=Register

It is very strange that I am able to get same parameters through POST method.

Below is the code I am using.

<?php

echo "Method 1<br/>";
print_r($_REQUEST);

echo "<br/>Method 2<br/>";
var_dump($_SERVER['REQUEST_URI']);

echo "<br/>Method 3<br/>";
var_dump($_SERVER['QUERY_STRING']);

3 Answers3

0

You can check your GET params by doing this:

var_dump($_GET);

Or you can also check:

var_dump($_SERVER['REQUEST_URI']);
var_dump($_SERVER['QUERY_STRING']);
lloiacono
  • 4,714
  • 2
  • 30
  • 46
0

First you should check you form type if is it a get type to get $_GET values

0

I know it's late. but maybe this answer helps another developer.

// get the value of outlink, source, campaign, medium, content

let url = new URL(window.location.href);
    let outlink = url.searchParams.get('outlink'), 
        utmSource = url.searchParams.get('utm_source'),
        utmCampaign = url.searchParams.get('utm_campaign'),
        utmMedium = url.searchParams.get('utm_medium'),
        utmContent = url.searchParams.get('utm_content');
        console.table( { outlink , utmSource, utmCampaign, 
        utmMedium,utmContent});
Sajeed Kannoje
  • 931
  • 1
  • 5
  • 13