glavca Posted September 30, 2009 Share Posted September 30, 2009 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. Quote Link to comment Share on other sites More sharing options...
gr1zzly Posted September 30, 2009 Share Posted September 30, 2009 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/ Quote Link to comment Share on other sites More sharing options...
thebadbad Posted September 30, 2009 Share Posted September 30, 2009 When you build the URLs, you should run the external URLs through urlencode(), and then urldecode() in activate.php. Quote Link to comment Share on other sites More sharing options...
glavca Posted September 30, 2009 Author Share Posted September 30, 2009 @ 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. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 30, 2009 Share Posted September 30, 2009 Look at what thebadbad has suggested. Quote Link to comment Share on other sites More sharing options...
cags Posted September 30, 2009 Share Posted September 30, 2009 <?php if(isset($_GET['url'])) { $link = urldecode($_GET['url']); echo $link; } ?> <a href="?url=<?php echo urlencode("http://www.site.com/something-dynamic-changing-link") ?>" />Linkname</a> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.