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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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