Using Wininet for HttpRequest POST

Hi everyone,

I am learning to make nttp requests, POST with wininet to a php file. the php file will then save the data to a database (mysql)

The Program compiles correctly with no errors, possibly i dont have an idea if it works correctly. I would like to know if i am correct.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <wininet.h>
#include <cstdlib>

#pragma comment(lib,"Wininet.lib")
#pragma comment(lib,"ulmon.lib")
#define POST 1
#define Request

using namespace std;

int main(int argc, _TCHAR* argv[])
{

char fname;
char lname;
char data;

wsprintfA(fname,lname,data);
Request(POST,"localhost","/data.php","Content-Type: application/x-www-form-urlencoded", fname,lname,data);

return 0;
}

Last edited on
The Program compiles correctly with no errors,

No, it doesn't.
i am using microsoft visual studio 2012. i dont get to see any error here.
i am using microsoft visual studio 2012. i dont get to see any error here.

That will not compile correctly on any C++ compiler. Is this your actual code or did you modify or re-type it to post?
I did some removals, here is what the code looks like now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <wininet.h>
#include <cstdlib>

#pragma comment(lib,"Wininet.lib")
#define POST 1
#define Request

using namespace std;

int main(int argc, _TCHAR* argv[])
{

char fname;
char lname;
char data;

//wsprintfA(fname,lname,data);
Request(POST,"localhost","/data.php","Content-Type: application/x-www-form-urlencoded", fname,lname,data);

return 0;
}


And it compiled. the first one didnt my mistake.
Sorry is this the correct way do send data via wininet to a php file.
Last edited on
Topic archived. No new replies allowed.