This program helps the user to register, login, edit details and find the username/password in case they forget. This program is made by using datafile handling , function and switch case.
Firstly we include all the neccessarry header files required in the program. Here we used iostream, istream, fstream, stdlib.h and string.h
Now we declare all the functions we will be needing to peform different tasks. Here we used login(), registr(), edit() and forgot(), all of type void.
In the main function we use the switch case to provide the user various options to choose from with the required function call.
Starting with the login() function, here we ask the user to enter username and password and use ifstream to access the datafile and check the entered details. If the user entered the credentials correctly then it will display "LOGIN SUCCESS" else it will display "LOGIN ERROR" and direct the user to the main() function.
Now, in registr() function we ask the user to enter the username, password and phone number and using ofstream store the data in the datafile called database. After user successfully enters the details it displays "REGISTRATION SUCCESSFUL" and directs the user to the main() function.
In forgot() function we provide the user with 3 options, one being to search for id using username, second being to search for id using password and third one redirecting the user to the main() function. To perform the functions we use switch case and ifstream to search for the password/username and once we find the match between entered value and the one in database file we display the password and username credentials to the user.
Finally in the edit() function, we provide the user an option to edit their username and password using switch case. Here initially ask the user to enter the new username or new password and the rest of the details and then we overwrite the information in the database file and successfully edit and update the details. Now the user will again be directed to the main() function.
Submitted by Dimple Singhvi (dimplesinghvi)
Download packets of source code on Coders Packet