Angoose Angoose - 1 month ago 5
HTML Question

Can the GET variables be extracted?

I'm trying to store GET variables using PHP from this URL string, but doesn't seem to be working...


domain.local/welcome?fwd=cd&data=%7B"email"%3A"example%40example.co.uk"%7D


The PHP I tried is:

$email = htmlspecialchars($_GET["email"]);


and also...

$email = $_GET["email"];


Neither is working, Any ideas please? (BTW I have no means to change the URL string)

Answer

Follow this :

your url is : domain.local/welcome??fwd=cd&data={"email":"example@example.co.uk"}

<?php
$fwd = $_GET['fwd']; //output cd
$data = json_decode($_GET['data']); //

echo $data->email; //output is example@example.co.uk
?>

if your url like data={"email":"example@example.co.uk","name":"myname","mobile":123456"}

Then you can use bellow example :

echo $data->name; //output myname
echo $data->mobile; //output 123456