简体   繁体   中英

How to detect GET parameters in URL, and place values according to that,?

I am working on a project in PHP and JavaScript, where i have to create a value from my end, and pass the same in URL query string on redirect from my URL, Below is Description: I have a URL, https://abc.amindfad.com/c.php?id= {abdid}

on above URL I want redirection, and pass value from my end by detecting where is {abdid}

The above URL will be redirecting from (my URL) :- https://console.adcashod.net/click.php

i have not done anything yet, Because i am little confused in Code which should be used here.

in Results I want that, when I click on (my URL) :- https://console.adcashod.net/click.php

it get redirects to :- https://abc.amindfad.com/c.php?id= {abdid} but,

replace {abdid} with a value which is defined by me. for it.

Waiting for suggestions.

Take a look at this https://www.php.net/manual/en/function.str-replace.php

$value = 'value_defined_by_me';
$url = 'https://abc.amindfad.com/c.php?id={abdid}';
$url = str_replace('{abdid}', $value, $url); //output: https://abc.amindfad.com/c.php?id=value_defined_by_me

As in simple

let url = new URL('https://abc.amindfad.com/c.php?id=value&name=john');

let searchParams = new URLSearchParams(url.search);

console.log(searchParams.get('id'));  // outputs "value"

console.log(searchParams.get('name'));  // outputs "john"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM