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 Link to comment https://forums.phpfreaks.com/topic/60870-solved-passing-urls-to-php/ 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. Link to comment https://forums.phpfreaks.com/topic/60870-solved-passing-urls-to-php/#findComment-302858 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. Link to comment https://forums.phpfreaks.com/topic/60870-solved-passing-urls-to-php/#findComment-302862 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. Link to comment https://forums.phpfreaks.com/topic/60870-solved-passing-urls-to-php/#findComment-302865 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...... Link to comment https://forums.phpfreaks.com/topic/60870-solved-passing-urls-to-php/#findComment-303684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.