Jump to content

Post data to a form using CURL


abhishekphp6

Recommended Posts

Hello,

 

I have written the following PHP code

 

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://ice.auspost.com.au/display.asp?ShowFirstScreenOnly=FALSE&ShowFirstRecOnly=TRUE');

curl_setopt ($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS,"txtItemNumber=EQ001125608AU");

$data = curl_exec ($ch);

curl_close($ch);

echo ' length of data: ' . strlen($data) . '<br/>';

?>

 

What I want is that the page should display the length of the output page which the script has created.

 

Instead what is happening is that the contents are being displayed on my page and the length of the output string is 1.

 

What I want is that the content of the resultant page is populated in my $data variable.

 

And I don't want to display the resultant page (result of posting to the asp page) to be displayed directly on my PHP page.

 

Can you please help!

Link to comment
https://forums.phpfreaks.com/topic/195173-post-data-to-a-form-using-curl/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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