Sending postdata to url

This is a discussion on Sending postdata to url within the Windows Programming forums, part of the Platform Specific Boards category; Hi I want to send html form data to a URL with a C++ program. I've been trying to google ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102

    Sending postdata to url

    Hi

    I want to send html form data to a URL with a C++ program. I've been trying to google something for the last 2 days, but found nothing. Maybe I'm a bad searcher. Could someone point me to the right direction by giving some links or advising on how to search?

    Thanks

  2. #2
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    Pure WinInet...see HttpSendRequest.
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  3. #3
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    I got a good tutorial on just that on my site. You can get it here.

  4. #4
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    Very good tutorial, Queatrix.

    However, I don't know how exactly should I send postdata.
    Code:
    char szPostData[ ] = "\0\0";
    HttpSendRequest( hRequest, szNewHeader, strlen(szNewHeader),
                                    szPostData, strlen(szPostData) );
    What format should it be?

    For example on this HTML form:
    Code:
    <form name="message" method="post" action="message.php">
    <input name="subject" type="text">
    Thanks again.

  5. #5
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    You have to know how the browser converts form data into a string, in this case szPostData should be:
    Code:
    char szPostData[ ] = "message=AAA&subject=BBB\0";
    This is assuming "AAA" is what was 'typed' into the message edit box, and "BBB" is what was 'typed' in the subject edit line.

  6. #6
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    Oh, if it's as easy as sending the postdata from url, then thanks very much!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending data - line by line?
    By tuckker in forum C Programming
    Replies: 0
    Last Post: 02-21-2009, 08:31 PM
  2. URL escape issue
    By George2 in forum C# Programming
    Replies: 2
    Last Post: 08-12-2008, 11:45 AM
  3. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  4. Replies: 1
    Last Post: 07-02-2007, 09:22 AM
  5. Url query encoding/decoding
    By Niara in forum Networking/Device Communication
    Replies: 6
    Last Post: 04-25-2007, 03:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21