|
-
Feb 14th, 2005, 06:51 PM
#1
Thread Starter
Ex-Super Mod'rater
VB6: Sending data to Web Server Scripts. -[RESOLVED]-
How would I be able to transmit data to the script as POST data or if there is a better way than that would be good too. Also I'd have to have a way to retrive the data sent back in reply from the script, be it Text or Binary.
Thanx
Last edited by Electroman; Feb 15th, 2005 at 06:23 PM.
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Feb 15th, 2005, 06:27 AM
#2
Re: VB6: Sending data to Web Server Scripts.
You will nedd to use Winsock to do this. Once you have established a connection to the server on port 80 you can then send the POST request.
Unlike the GET method which encodes the variables and names in the URL query string, the POST method encodes them in the main body of the HTTP request. The best type of encoding to use is the one the use for GET, URL encoding. Each name/value pair is seperated by an ampersand and any meta characters are converted to their hexadecimal exquivilent in the form:
Space = 3210 = %20
Heres an article on how to do this in VB: http://www.freevbcode.com/ShowCode.asp?ID=1512
The HTTP itself would look something like this:
Code:
POST /path/to/script.php HTTP/1.0\r\n
Content-Length:65\r\n
Content-Encoding: application/x-www-from-
urlencoded\r\n
\r\n
name=adam&age=21&occupation=student&hobbies[]=swim&hobbies[]=ring
This tutorial shows how to use winsock to send an HTTP request. While this explains how to downlaod a file using the GET method, you can easily change it fit the the POST method. The only difference is, is the reponse from the server won't always be 200, they often send a 302 response which indicates the client should redirect to the URL in the location header.
http://www.vbip.com/winsock/winsock_http_01.asp
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|