Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Login System :

    General and Desktop
    2
    4
    2292
    Loading More Posts
    • 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
      Amarda_4 last edited by

      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 Reply Quote 0
      • A
        Alek Śmierciak last edited by

        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 Reply Quote 0
        • A
          Amarda_4 last edited by

          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 Reply Quote 0
          • A
            Alek Śmierciak last edited by

            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 Reply Quote 0
            • First post
              Last post