redgum Posted July 19, 2007 Share Posted July 19, 2007 Hello, I'm trying to pass a URL from an html page thru to php. <a href="test.php?url=http://web.site.co.uk/script.cgi?a=1&b=2&c=3">test</a> and in test.php I've got... <?php $query = $_GET['url']; ?> however, the url doesn't get passed completely, nothing after the first & gets passed. e.g. I get http://web.site.co.uk/script.cgi?a=1 Any ideas please? Thanks Quote Link to comment Share on other sites More sharing options...
chigley Posted July 19, 2007 Share Posted July 19, 2007 Perhaps $_SERVER["QUERY_STRING"] could be useful? If not, I'd suggest encoding the URL and decoding at the other end. Quote Link to comment Share on other sites More sharing options...
trq Posted July 19, 2007 Share Posted July 19, 2007 I would think you would need to urlencode the... http://web.site.co.uk/script.cgi?a=1&b=2&c=3 before you could legitimately pass that through a url. Quote Link to comment Share on other sites More sharing options...
Alex007152 Posted July 19, 2007 Share Posted July 19, 2007 Probably quite long but this is some code i found some while ago when i had the same problem, if appropriate it copy's the entire url of the current page and puts it in $fullURL. $_SERVER['FULL_URL'] = 'http'; $script_name = ''; if(isset($_SERVER['REQUEST_URI'])) { $script_name = $_SERVER['REQUEST_URI']; } else { $script_name = $_SERVER['PHP_SELF']; if($_SERVER['QUERY_STRING']>' ') { $script_name .= '?'.$_SERVER['QUERY_STRING']; } } if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') { $_SERVER['FULL_URL'] .= 's'; } $_SERVER['FULL_URL'] .= '://'; if($_SERVER['SERVER_PORT']!='80') { $_SERVER['FULL_URL'] .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$script_name; } else { $_SERVER['FULL_URL'] .= $_SERVER['HTTP_HOST'].$script_name; } $_SESSION['thePageURL'] = $_SERVER['FULL_URL']; $fullURL = $_SESSION['thePageURL']; Hope it helped. Quote Link to comment Share on other sites More sharing options...
redgum Posted July 20, 2007 Author Share Posted July 20, 2007 Thanks Alex007152 - FIXED!! You've saved me going mad...... 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.