Jump to content

Getting url string of clicked link in php sript


glavca

Recommended Posts

Hi,

 

I have url's on my page like this '<a href="activate.php?url=http://www.site.com/something-dynamic-changing-link'>Linkname</a>

 

When user clicks on link, the script activate.php is executing. The problem is that I can't get the url string http://www.site.com/something-dynamic-changing-link in a variable $link in the activate.php script. The url's are dynamic, but they all begin with "activate.php?url="

 

How can I put the url string into variable $link, that is used in activate.php script?

 

Is this possible?

 

Please help.

You should be able to retrieve the url string, since it's being passed as part of a url query, using $_GET(). Something like...

 

if ( isset($_GET['url']) ) {
    $link = $_GET['url'];
} else {
// Default url <OR> Error message.
};

 

Note that you should also perform some kind of validation of the url string to make sure it is something that it's supposed to be, to protect against XSS attacks and the like. A quick google should help, or see http://php.robm.me.uk/

@ gr1zzly

 

Thanks for your code, but there is a little problem. I try your code, but didn't get the whole link.

 

link on my page: http://www.mypage.com/calculator.php?id=1196642&arb_uid=|AH%202,1|EH%20X,-1|EH%201,-1|&arb_type=TARB00X2&stakes[]=100&odds[]=1.3&odds[]=4.333&odds[]=7

 

the result in variable $link in activate.php http://www.mypage.com/calculator.php?id=1196642

 

I'm missing a part of a link.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.