C
C
chrispsow2018-12-18 15:46:19
PHP
chrispsow, 2018-12-18 15:46:19

How to organize the pulling of a specific value from the URL into the form?

There is a link domain.com/index.html?subacc4=asdffdsa123
There is a form with < input name="subid" type="hidden" value="{subid}" / >
subacc4 value needs to be inserted into subid somehow

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
MADSMILEXD, 2018-12-18
@chrispsow

< input name="subid" type="hidden" value="<?=$_GET['subacc4'];?>" / >

M
Mitya ToDaSyo, 2018-12-18
@dimastik1986

<?php
$url = 'http://username:[email protected]/path?arg=value#anchor';
print_r(parse_url($url));
echo parse_url($url, PHP_URL_PATH);

The result of running this example:
Array
(
[scheme] => http
[host] => hostname
[user] => username
[pass] => password
[path] => /path
[query] => arg=value
[fragment] => anchor
)

N
nvdfxx, 2018-12-18
@nvdfxx

let link = 'domain.com/index.html?subacc4=asdffdsa123&deat=ojdai33';
let cutLink = link.substr(link.lastIndexOf('?') + 1);
let url = new URLSearchParams(cutLink);
let subid = url.get('subacc4');
console.log(subid)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question