-1

I need to echo the value of key which is test. se url in picture.

URL is https://www.carlo.in/car_offers#getDiscounts?key=test

ggest

is any way to get data like this ?

<?php echo $_GET['key'];?> and Output : test.

24
  • do you need $_GET['key'] ?
    – Sfili_81
    Sep 17, 2019 at 6:59
  • see updated question Sep 17, 2019 at 6:59
  • problem is #getDiscounts in url Sep 17, 2019 at 7:00
  • 5
    Anything after # is ignored(we call it as URL fragment) and not sent to the server. The URL is poorly formed. It should indeed be https://www.carlo.in/car_offers?key=test#getDiscounts
    – nice_dev
    Sep 17, 2019 at 7:03
  • 1
    @RajendraSingh Ok, glad it's working now. But you need to fix the 2 times addition of car-offers in your hrefs.
    – nice_dev
    Sep 17, 2019 at 7:31

2 Answers 2

0

you can code like this

$key = $_GET['key'];

and if you echo $key, the result will be

echo $key;
// test

P/S : do not forget to sanitize if you are using the $key to query something from your DB.

1
  • i want to use value of key in this input code is here > <input style="border:1px solid #3879FF;" type="text" class="form-control" name="requirement" value="<?php echo $_GET['key'];?>" placeholder="Car Make/Model name"> Sep 17, 2019 at 7:02
0

No way with PHP because the parameter is a part of hash, You can place the parameter in HTML with Javascript or You can send the parameter to your server with Javascript and place some PHP answer in HTML then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.