RE: [PHP] curl and variable parameters in hyperlink

From: Date: Wed, 24 Nov 2010 07:30:39 +0000
Subject: RE: [PHP] curl and variable parameters in hyperlink
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-309646@lists.php.net to get a copy of this message
I already have a curl script that gets the web page, but it doesn't pass the parameters Being new to PHP I haven't the first idea how to modify it so that it does. Script is as follows: $url = "http://www.xxxxxx.com/query.asp?param1=val1&param2=val2"; foreach ($_POST as $key=>$post) { $post=str_replace(" ", "+", $post); $url.=$key."=".$post."&"; } $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); $data = curl_exec($ch); curl_close($ch); $data=str_replace('.asp', '.php', $data); echo $data; This returns the web page, but ignores val1 and val2 which are necessary to execute the query.

« previous php.general (#309646) next »