tags:

views:

173

answers:

2

Hi! I'm trying to use the cURL post-callback.c ex to submit a local html form to a remote form script. I need to know what the script does with the URL/httpheader after it is done handling the post so I know if the post succeeded or not (went to success page).

I can't figure out exactly how to write the data I need posted. (syntax, method) and how to retrieve and display the redirected url after the script has run.

There are two form fields to be posted: name="row1" and name="value1". How do I put this in the data array correctly?

Thank you! :)

A: 

Check out this great intro to the HTTP protocol: http://www.jmarshall.com/easy/http/#postmethod

You'll need to send a POST command to the HTTP server, and then examine the server's response. I created a PHP file on my webserver called post.php, and all it does is

print_r($_POST);

Now I'll post some data to it via Telnet:

justin:~ justin$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
POST /~justin/post.php HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 36

key1=value1&key2=value2&key3=value3

And examine the server's response:

HTTP/1.1 200 OK
Date: Sat, 17 Oct 2009 06:39:02 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k DAV/2 PHP/5.3.0
X-Powered-By: PHP/5.3.0
Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/
Content-Length: 81
Connection: close
Content-Type: text/html

<pre>
Array
(
    [key1] => value1
    [key2] => value2
    [key3] => value3
)

Server says "HTTP/1.1 200 OK", so it worked.

Now, as for the cURL example, you need to package up a similar POST command into a string (which of course is an array of chars, in C). If you're new to working with strings in C, look online for examples, you'll find lots.

echo
A: 

can you talk to me how to compile post-callback.c ? i'm stuck in compile post-callback.c .

shadow