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.

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

@ 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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.