Reputation: 887
Say I have the following URL:
When I do the following:
echo ($_GET["url"]);
I get the following:
https://www.domain.com/LoanRequest/page.aspx?CUID=10414424
It isn't the entire link and I know why - it assumes the "&" is for a new variable...
How do I grab the entire link or is there certain way the original link needs be coded?
Upvotes: 0
Views: 63
Reputation: 887
This is what we ended up doing based on TecBrat's suggestion:
//get URL
$offsite_url = $_SERVER['REQUEST_URI'];
//break about URL
$offsite_url = str_replace('/?page=offsite&url=', '' , $offsite_url);
//clean input
$offsite_url = cleaninput($offsite_url);
(cleaninput is a sanitizing function)
I don't think it is the ideal solution (maybe it is - open to feedback), but it appears to be working. urlencode seems like a better solution, but that wasn't an option.
Upvotes: 0
Reputation: 3729
If the structure of the offsite url is unpredictable, then I'd use $_SERVER['QUERY_STRING']
and pull off what I need with string functions. If it is predictable, the I'd use the answer given by Maxiums2012 unless you also control the link, then I'd suggest, as others have, to urlencode the offsite url before sending it.
Upvotes: 1
Reputation: 4908
If you create the original link, you should pass all query vars from url encode
Like
$q_url = 'https://www.domain.com/LoanRequest/page.aspx?CUID=10414424&LOID=850&ChannelId=4078715104014180815';
$url = 'http://www.domain.net/?page=offsite&url='.urlencode($q_url);
Then by $_GET["url"]
you should get the whole url
Upvotes: 0
Reputation: 93805
The URL you have is incorrect, then.
The URL base URL is
http://www.domain.net/
and its parameters are
page=offsite
url=https://www.domain.com/LoanRequest/page.aspx?CUID=10414424
LOID=850
ChannelId=4078715104014180815
If you want the LOID and ChannelID to be associated with that url= parameter, then it should be encoded with urlencode() as
http://www.domain.net/?page=offsite&url=https://www.domain.com/LoanRequest/page.aspx?CUID=10414424&LOID=850&ChannelId=4078715104014180815
Upvotes: 0
Reputation: 1819
Can you try this:
$link = $_GET['url'] . "&LOID=" . $_GET['LOID'] . "&ChannelID=" . $_GET['ChannelID'];
The way your original URL is defined, 'url' will only be treated as one of the GET parameters which means you need to separately get other GET parameters in order to construct the complete URL. UPDATE: changed the url variable according to suggestion from Ben Fortune.
Upvotes: 2