Results 1 to 6 of 6

Thread: [SOLVED] MySQL - Check credentials?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2012
    Posts
    13
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up [SOLVED] MySQL - Check credentials?

    I've done this in PHP, but for QT i'm not finding much documentation. I compiled the QMYSQL driver (finally), I'm connected to my local DB and all I need to do now is to compare the user supplied username and password against the database. I have already hashed & salted the password.

    This is what I currently have, which is not working. More specifically, it is now saying that anything I enter is valid. Please note, QSqlQuery.lastError() is returning a null string.

    I echoed the credentials just before the query is executed, everything is proper. I can't think of what it could be.

    Qt Code:
    1. query.prepare("SELECT UID, PWD FROM login WHERE UID=? AND PWD=?");
    2. query.addBindValue(username);
    3. query.addBindValue(password);
    4.  
    5. if(!query.exec())
    6. {
    7. msg.setText(query.lastError().text());
    8. msg.exec();
    9. }
    10.  
    11. QSqlRecord record = query.record();
    12. int cols = record.count();
    13.  
    14. if(cols > 0)
    15. {
    16. msg.setText("Good");
    17. return true;
    18. }
    19. else
    20. {
    21. msg.setText("Bad");
    22. return false;
    23. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by xyz247; 28th October 2012 at 04:34.

Similar Threads

  1. Check credentials using QSql
    By death_star in forum Qt Programming
    Replies: 6
    Last Post: 26th January 2011, 06:16
  2. How to save credentials in local keychain
    By kalos80 in forum Qt Programming
    Replies: 4
    Last Post: 9th November 2010, 11:08
  3. I need MySQL driver for Qt 4.6, WindowsXP(32), MySQL 5.1
    By User_3 in forum Installation and Deployment
    Replies: 7
    Last Post: 15th October 2010, 15:19
  4. Check if a table exists in a mysql database
    By graciano in forum Qt Programming
    Replies: 8
    Last Post: 5th November 2009, 02:44
  5. MYSQL 5 Table qt model as small Mysql admin
    By patrik08 in forum Qt-based Software
    Replies: 0
    Last Post: 1st May 2007, 09:43

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.