Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you pass GET values to another url in php? GET value forwarding

Ok, so I'm using Jquery's AJAX function and it's having trouble passing a URL with a http address. So I'm hoping to "get" the GET values and send them to another URL — so: a local php file begin passed GET values, which in turn forwards the GET values to another url.

Maybe curl is the answer? I don't know. It's got to be a very short answer I know.

pseudo code:

//retrieve the GET values
$var retrieve [GET]

//passing it to another url
send get values to url ($var, url_address)

edit: It's a cross scripting solution for JavaScript.

like image 365
michael Avatar asked Apr 27 '10 03:04

michael


1 Answers

If you want to redirect the user:

header('Location: http://example.com/page.php?' . http_build_query($_GET, '', '&')); die();

If however you just want to fetch the page, use this:

file_get_contents('http://example.com/page.php?' . http_build_query($_GET, '', '&'));
like image 91
Alix Axel Avatar answered Sep 20 '22 02:09

Alix Axel