GET method... Extract variables

306 Views Asked by At

Can someone help me how to extract the url parameters from the following url using GET method in php?

http://domainname.com/?formBuilderForm%5BFormBuilderID%5D=29&formBuilderForm%5Brandomizer%5D=508398db941a26.20741366&formBuilderForm%5Bvw_sre_ticker_name%5D=TPX&formBuilderForm%5Bvw_sre_entry_price%5D=100&formBuilderForm%5Bvw_sre_entry_date%5D=21%2F10%2F2012

I believe the variable name is formBuilderForm [FormBuilderID] and value is 29. I tried the following code but it didn't work.

<?php
$_vw_sre_ticker_name_in = $_GET["formBuilderForm [FormBuilderID ]"];
echo 'vw_sre_ticker_name'.$vw_sre_ticker_name_in;
?>

I believe, it something to do with ASCII and Non-ASCII stuff.

2

There are 2 best solutions below

2
On

%5D stands for [ in url encodings

So you could probably try

<?php
 $_vw_sre_ticker_name_in = $_GET["formBuilderForm[FormBuilderID]"];
 echo 'vw_sre_ticker_name'.$vw_sre_ticker_name_in;
?>

You needed to remove the spaces.

However as pointed out by Seth, this is really really basic debugging a simple

print_r($_GET);

Would have provided you with the information you needed rather than asking on Stackoverflow.

0
On

You can use foreach on $_GET

foreach($_GET as $key=>$value) {
       echo $key . ':' . $value;
}