Results 1 to 8 of 8

Thread: [Qt/Sql] SQL Authentification : what query execute ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2013
    Posts
    5
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question [Qt/Sql] SQL Authentification : what query execute ?

    Hi!

    First of all, you need to now that I'm not very fluent in English, then be lenient if some of my explanation are not very good.

    I'm trying to create some sort of authentication software on my stage, we give a pair username / pwd then the software must check whether the username exists in the database then check if pwd matches.
    But I stumble on two problems :

    - The first : the pwd stored in the SQL database are hashed (and maybe salty), and I wonder if with Qt, it could be hashed and salted in the same way so that both pwd correspond to history compare, if so, how?
    - The second : I don't know what to request and what order to perform the above steps, I would like to know if you could also help me on this point (possibly with specific code).

    Here is my actual code ( these are just attempts ):

    Qt Code:
    1. void loginFen::buttonConnect_onClicked()
    2. {
    3. QSqlQuery query;
    4. query.prepare("SELECT mdp from users WHERE pseudo=:pseudo");
    5. query.bindValue(":pseudo", pseudo->text());
    6.  
    7. if(query.exec())
    8. {
    9. //query.first();
    10. if(query.value(2).toString() == password->text()) // the problem is here
    11. {
    12. close();
    13. Fenetre *Fen = new Fenetre;
    14. Fen->show();
    15. Fen->loadStyle();
    16. }
    17. else
    18. {
    19. QMessageBox::information(this, "Erreur de saisie", "Le mot de passe que vous avez entré est incorrect, veuillez réessayer"); // wrong password
    20. }
    21. }
    22. else
    23. {
    24. QMessageBox::information(this, "Erreur de saisie", "Le pseudo que vous avez entré est incorrect, veuillez réessayer"); wrong pseudo
    25. }
    To copy to clipboard, switch view to plain text mode 

    Thanks for your help anyway & thank you to tell me if it is not accurate enough, in which case, I'll explain again my problem !

  2. The following user says thank you to CR4SH for this useful post:


Similar Threads

  1. Lua + C++ Function Execute
    By steadi in forum Newbie
    Replies: 1
    Last Post: 2nd December 2012, 17:44
  2. QSqlQuery does not execute
    By weixj2003ld in forum Qt Programming
    Replies: 7
    Last Post: 11th July 2012, 12:13
  3. Execute a .sql file with more than one query
    By ShadowBelmolve in forum Newbie
    Replies: 6
    Last Post: 19th August 2010, 16:48
  4. Can execute examples
    By gyre in forum Qwt
    Replies: 12
    Last Post: 26th February 2010, 08:51
  5. Replies: 2
    Last Post: 5th March 2008, 10:39

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.