0% found this document useful (0 votes)
20 views6 pages

Scriptfinal

This document describes a simple menu-driven program with options for login, registration, forgot password, and exit. It includes code snippets to implement the functions for each option using concepts like header files, functions, variables, input/output, file handling, and if/else statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

Scriptfinal

This document describes a simple menu-driven program with options for login, registration, forgot password, and exit. It includes code snippets to implement the functions for each option using concepts like header files, functions, variables, input/output, file handling, and if/else statements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

In this simple project, we have a menu page, and it contains options that users will

select. These options are login, registration, forgot password, and exit program. Then
once the user selects an option, it will proceed to the functionality of that option. But
before we run the program, let us first see how we implement the program in an IDE.

First are the header files. The #include <iostream> is to access the iostream library
that allow us to use input and output functions in our program. The #include <fstream>
is to access the fstream library that allow us to use the file handling functions for the
database where we store the user’s usernames and passwords. While using
namespace std … tbh di ko alam kung ano function nyan basta importante yan sa
program naten haha.

We assign void to the functions: login, registration, and forgotPass (forgot


password), as a forward declaration.
int main ()

This will be the program output or the main menu page with options for users to select
from. Also, the variable name choice would be assigned as an integer because the
expected user inputs would be whole numbers 1 to 4.

We use switch case statements for the expression choice to call the respective
functionalities of the options the user selects. If the user selects 1, then it will call the
login function. If the user selects 2, then it will call the registration function, and so on
and so forth.
void login()

For the login function, we must first assign the variables. int count is 0 and
logUsername, logPass, recUsername, and recPass as string.
Line 57 to 68 is the login function’s display output, and it will ask the username
(logUsername) and password (logPass) of your account you want to logged in.

Once the username and password has been entered, we use ifstream to read if the
username (logUsername) and password (logPass) are recorded in the [Link] file
or the database. If the username and password does exist in the database, count will
become 1.
if count is equal to 1, then it will display an output that you have logged in successfully.
This means that the username and password are already registered in the database.
else, it will display an output saying, “login error”. This means that the username,
password, or both, are not registered in the database.

void registration()

For the registration function, we assign regUsername and regPass as string.


Line 102 to 114 is the regitration function’s display output, and it will ask the username
(regUsername) and password (regPass) for registering a new account.
Once the username and password for the new account has been entered, we use
ofstream to write or record the entered username and password inside the [Link]
file or the database. Then, it will display an output that you have successfully
registered.
void forgotPass()

For the forgot password function, again, we assign the variables. int count is 0 and
Username, forUsername, and forPass as string.
Line 127 to 137 is the forgot password function’s display output, and it will ask the
username (Username) to determine its password (forPass).
Once the username has been entered, we use ifstream, again, to read if the username
(Username) is recorded in the [Link] file or the database. If the username and
password does exist in the database, count will become 1.
if count is equal to 1, then your account exists in the database, and it will display its
password.
else, it will display an output saying, “account is not found”. This means that the
username is not registered in the database.

Now, we can run the program.

You might also like