Unsolved Registration and login Patient system
-
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?
-
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).
-
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.
-
Safety measures like that are worth bonus points.
Which solution are you talking about ?