Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Login System :

Login System :

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amarda_4
    wrote on last edited by
    #1

    I'm using Qt creator and i'm trying to do a login system about the administrator of my database in MySql
    I dont now how to compare my values(name and password,which I have in a class called Admin) with the real values on database.
    Anyone could help pls ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Alek Śmierciak
      wrote on last edited by
      #2

      Your database user table should contain logins, salted password hashes and randomly generated "salts":https://en.wikipedia.org/wiki/Salt_(cryptography).
      User authentication would involve a SELECT query for a password hash and a salt of the corresponding login (for example given by user in the login window), and a comparison of password hash from the database with the given password, concatenated with salt and hashed.

      Basically, perform a SELECT, save the query result in QStrings and follow the above.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Amarda_4
        wrote on last edited by
        #3

        Here is my code:
        @#include<QSqlDatabase>
        #include<QSqlQuery>
        #include<iostream>
        #include<Database.cpp>
        #include<Administratori.cpp>
        using namespace std;
        class Votuesi
        {
        public:

        string v_id ,emer,mbiemer,atesia,qarku,pass;
        public:
        Votuesi(string id,string qark,string pas)
        {
        v_id=id;
        qarku=qark;
        pass=pas;
        }
        void identifikohu()
        {

        QString sQuery=("SELECT * FROM evoting WHERE v_id = ? AND qyteti = ? AND pass = ? ");
        

        QSqlQuery query3;
        query3.prepare(sQuery);
        query3.addBindValue(v_id);
        query3.addBindValue(qarku);
        query3.addBindValue(pass);
        query3.exec();
        if (query3.size()>0)
        {
        qDebug() <<"Identifikimi u krye me sukses,ju jeni nje votues i vlefshem";}
        else
        {
        qDebug() <<"Te dhenat tuaja jane te pasakta";
        }
        }
        };

        int main()
        {
        Database db;
        db.lidhDatabase();
        Votuesi votuesi("12345","Rome","Ana");
        votuesi.identifikohu();
        }@

        The problem is on line 25,26,27..I can't take the values from my constructor to make a comparison with those values in database

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Alek Śmierciak
          wrote on last edited by
          #4

          What do you mean that you can't? What is the actual outcome and the expected one?

          On a side note, you should be using QStrings and by any chance not mix them up with STD strings.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved