#include "thewge.h"
#include "ui_thewge.h"
#include <QtGui/QApplication>
#include <QSignalMapper>
#include <QPushButton>
#include <windows.h>
#include <iostream>
#include "md5.h"
#include "mysql++.h"
TheWGE
::TheWGE(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
QObject::connect(ui.
LoginBtn,
SIGNAL(clicked
()),
this,
SLOT(login
()));
}
TheWGE::~TheWGE()
{
//ui.usrLineEdit->clear();
//ui.pwdLineEdit->clear();
}
void TheWGE::login()
{
if (ui.usrLineEdit->text().trimmed().isEmpty() )
{
ui.usrLineEdit->setFocus();
}
else if (ui.pwdLineEdit->text().trimmed().isEmpty() )
{
ui.pwdLineEdit->setFocus();
}
mysqlpp::Connection con(false);
if (!con.connect("Database", "host", "username", "password"))
{
qApp->exit(0);
}
// Retrieve a subset of the sample stock table set up by resetdb
mysqlpp::Query query = con.query();
QString Qstr1
= ui.
usrLineEdit->text
();
QString Qstr2
= ui.
pwdLineEdit->text
();
char *acsUserName = new char[ Qstr1.length() + 1 ]; // + 1 for zero in the end of string
memcpy( acsUserName, Qstr1.toUtf8().constData(),Qstr1.length() );
char *acsPassword = new char[ Qstr2.length() + 1 ]; // + 1 for zero in the end of string
memcpy( acsPassword, Qstr2.toUtf8().constData(), Qstr2.length() );
query << "SELECT username, password FROM wge_db_user WHERE username = '" << acsUserName << "' and password = '" << md5(acsPassword) << "'";
mysqlpp::StoreQueryResult res = query.store();
mysqlpp::Row row;
delete []acsUserName;
delete []acsPassword;
if (res.num_rows() > 0)
{
qApp->exit(0);
//goodlogin - show new form and hide this form
}
else
{
//qApp->exit(0);
//badlogin
}
mysqlpp::Connection::thread_end();
return;
}
#include "thewge.h"
#include "ui_thewge.h"
#include <QtGui/QApplication>
#include <QSignalMapper>
#include <QPushButton>
#include <windows.h>
#include <iostream>
#include "md5.h"
#include "mysql++.h"
TheWGE::TheWGE(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QObject::connect(ui.LoginBtn, SIGNAL(clicked()), this, SLOT(login()));
}
TheWGE::~TheWGE()
{
//ui.usrLineEdit->clear();
//ui.pwdLineEdit->clear();
}
void TheWGE::login()
{
if (ui.usrLineEdit->text().trimmed().isEmpty() )
{
ui.usrLineEdit->setFocus();
}
else if (ui.pwdLineEdit->text().trimmed().isEmpty() )
{
ui.pwdLineEdit->setFocus();
}
mysqlpp::Connection con(false);
if (!con.connect("Database", "host", "username", "password"))
{
qApp->exit(0);
}
// Retrieve a subset of the sample stock table set up by resetdb
mysqlpp::Query query = con.query();
QString Qstr1 = ui.usrLineEdit->text();
QString Qstr2 = ui.pwdLineEdit->text();
char *acsUserName = new char[ Qstr1.length() + 1 ]; // + 1 for zero in the end of string
memcpy( acsUserName, Qstr1.toUtf8().constData(),Qstr1.length() );
char *acsPassword = new char[ Qstr2.length() + 1 ]; // + 1 for zero in the end of string
memcpy( acsPassword, Qstr2.toUtf8().constData(), Qstr2.length() );
query << "SELECT username, password FROM wge_db_user WHERE username = '" << acsUserName << "' and password = '" << md5(acsPassword) << "'";
mysqlpp::StoreQueryResult res = query.store();
mysqlpp::Row row;
delete []acsUserName;
delete []acsPassword;
if (res.num_rows() > 0)
{
qApp->exit(0);
//goodlogin - show new form and hide this form
}
else
{
//qApp->exit(0);
//badlogin
}
mysqlpp::Connection::thread_end();
return;
}
To copy to clipboard, switch view to plain text mode
Bookmarks