Justin Patrin wrote:
On Wed, 04 Aug 2004 16:01:31 -0500, Jeff Oien <[EMAIL PROTECTED]> wrote:

I'm using the code below to post form data to an ASP script. But I need
to redirect to a "thank you" page when it all done or the person filling
out the form sees what they're not supposed to see. Any way I can do
this? If take out the last line and print a header(URL) it won't post
the data. Thanks
Jeff
-----------------
function http_post($host, $path, $data)
{
     $http_response = '';
     $content_length = strlen($data);

     $fp = fsockopen($host, 80);
     fputs($fp, "POST $path HTTP/1.1\r\n");
     fputs($fp, "Host: $host\r\n");
     fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
     fputs($fp, "Content-Length: $content_length\r\n");
     fputs($fp, "Connection: close\r\n\r\n");
     fputs($fp, $data);
     while (!feof($fp))
     {
          $http_response .= fgets($fp, 128);
     }
     fclose($fp);

     return $http_response;
}

$arr = array();

foreach($_POST as $key => $value) {
       $arr[] = $key.'='.urlencode($value);
}

$data = implode('&',$arr);

$http_response = http_post('www.blah.com', '/test.aspx?', "$data");
print "$http_response";


replace the print with: header('Location: http://example.com');

Then the data won't submit. cURL doesn't seem to help:

$URL="www.abc.com/VendorSubmitEx_test.aspx?";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://$URL";);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$data");curl_exec ($ch);
curl_close ($ch);

Second to last line sends a header and I can't redirect.
Jeff

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to