Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Registration and login Patient system
Forum Updated to NodeBB v4.3 + New Features

Registration and login Patient system

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
login
4 Posts 2 Posters 1.2k Views 2 Watching
  • 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.
  • Y Offline
    Y Offline
    Youssef_n9212
    wrote on last edited by
    #1

    I am trying to create a c++ patient system where the patient must register/login to access its features.
    So i used the following QFiles code to write into a .txt file to save the information entered by the user when they register.

    QFile file("Users.txt");
        if(!file.open(QFile::WriteOnly | QFile::Text))
        {
            QMessageBox::warning(this, tr("ERROR"), tr("File is missing, please check the path!"), QMessageBox::Close);
        }
        QTextStream write(&file);
        QString Username=ui->username->text();
        QString Password=ui->pass->text();
        QString Name=ui->name->text();
        QString Email=ui->email->text();
        QString Address=ui->addr->text();
        QString Age=ui->age->text();
        QString Gender=ui->gen->currentText();
        QString Bloodtype=ui->bt->currentText();
        QString Phone=ui->pnum->text();
        QString Ename=ui->ename->text();
        QString Enum=ui->epnum->text();
    
        write<<Username<<'\n'<<Password<<'\n'<<Name<<'\n'<<Email<<'\n'<<Address<<'\n'<<Age<<'\n'<<Gender<<'\n'<<Bloodtype<<'\n'<<Phone<<'\n'<<Ename<<'\n'<<Enum<<'\n';
        file.flush();
        file.close();
    

    It works perfectly and the data is entered into the file. Now, when logging in the program should compare the username and password entered in the login page to the ones in the file (the first 2 lines respectively) and if they match then the user should be allowed to login and if not, the user has to write the correct username and password. How can i do so?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      The answer to your question: write a dialog that takes the user input then in the slot connected to the "Login" button do your check and if good continue.

      Another possibility is to have a while loop that shows the dialog, when clicked on login, close the dialog, retrieve the information and do the check there, if there's a mismatch, continue the loop until either cancel is clicked or the correct value entered.

      Now the elephant in the room: storing personal and sensitive data in plain text in a text file ? That is wrong on too many levels to count. Since it's a patient system it means you may have a lot of people with their data stored, thus you will also need to find them, update their data and likely do other operations. Move the data storage to a database. No need to start with PostgreSQL now, SQLite should be just fine to get started. Then: encrypt the password ! You should also encrypt the patient information at some point (not the same encryption though).

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        Youssef_n9212
        wrote on last edited by
        #3

        This is just for a university project and does not require any safety measures of that sort, also if you can provide the syntax or code for the solution you presented that would be great.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Safety measures like that are worth bonus points.

          Which solution are you talking about ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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