-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyconnect.cpp
46 lines (36 loc) · 1.18 KB
/
myconnect.cpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "myconnect.h"
#include <iostream>
#include <string>
#include <QUrl>
#include <QDebug>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QApplication>
MyConnect::MyConnect()
{
}
void MyConnect::MyPostRequest(const QString &name)
{
QUrl url("http://webservices.pongsit.com/cs340/index.php");
QNetworkRequest request = QNetworkRequest(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QNetworkAccessManager * TheNetworkManager = new QNetworkAccessManager(this);
QByteArray postData;
postData.append("auth").append("=").append(name);
connect(TheNetworkManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply *)));
TheNetworkManager->post(request,postData);
}
void MyConnect::replyFinished(QNetworkReply *reply)
{
// QByteArray response = reply->readAll();
// QString responsStr(response);
// if(responsStr.compare("Good") == 0){
// qDebug() << "The response: " << responsStr;
// this->hide();
// Page2 page2;
// page2.setModal(true);
// page2.showInfo(responsStr);
// page2.exec();
// }
}