Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [C++] libCurl problem POST
toaspzoo
post 10.05.2011, 18:49:19
Post #1





Grupa: Zarejestrowani
Postów: 778
Pomógł: 84
Dołączył: 29.07.2010
Skąd: Gliwice / Pławniowice Mistrz niezmordowanej klawiatury.

Ostrzeżenie: (20%)
X----


Witam, nie wiedziałem, gdzie napisać, więc piszę tu...

mam problem z biblioteką libCurl, a mianowicie chce, żeby zamiast wpisanych na stałe danych zmiennych dać te ze zmiennych wpisanych przez użytkownika.


Oto kod:
Kod
#include <stdio.h>
#include <curl/curl.h>
#include <conio.h>
#include <iostream>
#include <fstream>

using namespace std;
int main(){



CURL *curl;
CURLcode res;

curl = curl_easy_init();

if(curl) {
   curl_easy_setopt(curl, CURLOPT_URL, "http://znajomek.unixstorm.org/logowanie.php");
   curl_easy_setopt(curl, CURLOPT_POST, 1);
   curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "login="lol&haslo=lol2");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);

cout << endl;
}
system("pause");
}


a chcę

Kod
#include <stdio.h>
#include <curl/curl.h>
#include <conio.h>
#include <iostream>
#include <fstream>

using namespace std;
int main(){

string login,haslo, dane;

cout << "Wpisz login: ";
cin >> login;
cout <<endl << "Haslo: ";
cin >> haslo;
cout << endl;

dane = "login=",login,"&haslo=",haslo;


CURL *curl;
CURLcode res;

curl = curl_easy_init();

if(curl) {
   curl_easy_setopt(curl, CURLOPT_URL, "http://znajomek.unixstorm.org/logowanie.php");
   curl_easy_setopt(curl, CURLOPT_POST, 1);
   curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dane);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);

cout << endl;
}
system("pause");
}


I po włączeniu app'a wywala mi błąd ....
pomocy ;(


--------------------

LS Easter egg <
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 17.06.2025 - 11:16