Skip to content

Instantly share code, notes, and snippets.

@erayarslan
Created July 17, 2014 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erayarslan/7af404dde12b39b7f706 to your computer and use it in GitHub Desktop.
Save erayarslan/7af404dde12b39b7f706 to your computer and use it in GitHub Desktop.
MD5 Login
#include <windows.h>
#include "md5.h"
#include "include/mysql.h"
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
MD5 sifrele;
string kadi;
string sifrelenmis;
char sifre[100];
cout<<"Kullanici Adi : ";
cin>>kadi;
cout<<"Sifre : ";
cin>>sifre;
sifrelenmis=sifrele.digestString(sifre);
ostringstream query;
query << "select count(*) from kullanicilar where kullaniciadi = '"<<kadi<<"' and sifre = '"<<sifrelenmis<<"'";
MYSQL *_MySQLConnection = mysql_init(NULL);
mysql_real_connect(_MySQLConnection,"mysqlhostip", "mysqlkullaniciadi", "mysqlsifre", "mysqlveritabani", 0, NULL, 0);
mysql_query(_MySQLConnection, query.str().c_str());
MYSQL_RES *result = mysql_store_result(_MySQLConnection);
MYSQL_ROW row;
while ((row = mysql_fetch_row(result)))
{
int i = atoi (row[0]);
if(i>=1)
{
cout<<endl<<">Giris Yapildi";
}
else
{
cout<<endl<<">Uzgunuz , ...";
}
}
mysql_free_result(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment