Jump to content

[SOLVED] Passing urls to php


redgum

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

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