0

Possible Duplicate:
How to read a web page in PHP

I'm sure there is some simple way to do this. I need to pass get variables through to my cart software to record a conversion, but not redirect the user, I just want the server to send GET variables to a URL. I'd rather not turn on allow_url_fopen in php.ini.

Anyone know the best way to do this? Thanks in advance.

Community
  • 1
  • 1
Snapcaster
  • 159
  • 1
  • 1
  • 7
  • 2
    You can do an [AJAX](http://en.wikipedia.org/wiki/Ajax_(programming)) request. – Aamir Nov 09 '12 at 01:27
  • 3
    Or use [**cURL** or one of the other PHP functions](http://stackoverflow.com/questions/2259892/how-to-read-a-web-page-in-php/2259893#2259893) to do a server-side request. – mario Nov 09 '12 at 01:31

1 Answers1

0

Server side, your best option is probably to use cURL - see the documentation for details, it's not too difficult to use.

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://www.example.com/script.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

curl_close($ch);

if ($response === false) {
    // Failed to connect or some error occurred
} else {
    // Everything was fine, check the response here if you need to
}
Kelvin
  • 5,227
  • 1
  • 23
  • 36