Results 1 to 2 of 2

Thread: VB6: Sending data to Web Server Scripts. -[RESOLVED]-

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    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.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width