RamboJustRambo Posted November 18, 2008 Share Posted November 18, 2008 Hi, basically i have a php file which takes an input as a url (such as " http://www.test.com/index.php?name=andy&friend=john ") However,whenever i pass this into my php file via $_GET, i end up with: http://www.mysite.com/file.php?site=http://www.test.com/index.php?name=andy&friend=john which my PHP doesn't like. Ifi hard code the link as a variable, it's fine, but since this is impossible to work with. Anyone have a work around? I don't need to access the variables, just accept the URL as an input for the file. Thanks for any help =] Link to comment https://forums.phpfreaks.com/topic/133195-passing-url-into-php-file-via-get-which-contains-variables/ Share on other sites More sharing options...
Guardian-Mage Posted November 18, 2008 Share Posted November 18, 2008 You need to urlencode the slashes in the url. http://ca.php.net/manual/en/function.urlencode.php Link to comment https://forums.phpfreaks.com/topic/133195-passing-url-into-php-file-via-get-which-contains-variables/#findComment-692736 Share on other sites More sharing options...
Maq Posted November 18, 2008 Share Posted November 18, 2008 Not tested. $encoded_site = urlencode("http://www.test.com/index.php?name=andy&friend=john"); $pass = "http://www.mysite.com/file.php?site=".$encoded_site; echo $pass; //may have to use echo urldecode($pass) to view properly Link to comment https://forums.phpfreaks.com/topic/133195-passing-url-into-php-file-via-get-which-contains-variables/#findComment-692743 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.