Login System :

  • 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 ?

  • 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.

  • Here is my code:
    using namespace std;
    class Votuesi

    string v_id ,emer,mbiemer,atesia,qarku,pass;
    Votuesi(string id,string qark,string pas)
    void identifikohu()

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

    QSqlQuery query3;
    if (query3.size()>0)
    qDebug() <<"Identifikimi u krye me sukses,ju jeni nje votues i vlefshem";}
    qDebug() <<"Te dhenat tuaja jane te pasakta";

    int main()
    Database db;
    Votuesi votuesi("12345","Rome","Ana");

    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

  • 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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.