Login page using c++ code .
for more projects link
--------------------------------------------------------------------------------------------------------------------------------
CODE :-
#include<iostream>#include<fstream>using namespace std;class temp{ string username, email, password; string searchname, searchpass,searchemail; fstream file; public: void login(); void signup(); void forgetpassword(); void exit();}obj;int main(){ char choices; cout<<"\n 1- login"; cout<<"\n 2- signup"; cout<<"\n 3- forget password"; cout<<"\n 4- Exit"; cout<<"enter your choice:: "; cin>>choices; switch (choices) { case '1': obj.login(); break; case '2': obj.signup(); break; case '3': obj.forgetpassword(); break; case '4': return 0; default: cout<<"envalid option"; }
return 0;}void temp ::signup(){ cout<<"enter your name ::"; getline(cin,username); cout<<"enter your email::"; getline (cin,email); cout<<"enter your password"; getline(cin,password); file.open("logindata.txt",ios::out| ios::app); file<<username<<" *"<<email<<" *"<<password<<endl; file.close();}void temp :: login(){ string searchname, searchpass; cout<<" ------LOGIN------ "<<endl; cout<<"enter you user name:"<<endl; getline(cin,searchname); cout<<"enter your password:"<<endl; getline(cin,searchpass);
file.open("logindata.txt",ios ::in); getline(file,username,'*'); getline(file,email,'*'); getline(file,password,'\n'); while(!file.eof()){ if(username==searchname){ if(password==searchpass){ cout<<"\n you are sucessfully login...."; cout<<"\n your username ::"<<username; cout<<"\n your email ::"<<email; } else{ cout<<"password is in correct"; } } getline(file,username,'*'); getline(file,email,'*'); getline(file,password,'\n'); } file.close();
}void temp :: forgetpassword(){ cout<<"\n enter your username ::"; getline(cin,searchname); cout<<"\n enter your email::"; getline (cin,searchemail); file.open("logindata.txt",ios :: in); getline(file,username ,'*'); getline(file,email ,'*'); getline(file, password,'\n'); while (!file.eof()){ if(username == searchname) if(email == searchemail){ cout<<"account found "; cout<<" your password "<<password<<endl;
} else{ cout<<"record not found"; } else{ cout<<" not found"; } } file.close(); }
#include<iostream>
#include<fstream>
using namespace std;
class temp{
string username, email, password;
string searchname, searchpass,searchemail;
fstream file;
public:
void login();
void signup();
void forgetpassword();
void exit();
}obj;
int main(){
char choices;
cout<<"\n 1- login";
cout<<"\n 2- signup";
cout<<"\n 3- forget password";
cout<<"\n 4- Exit";
cout<<"enter your choice:: ";
cin>>choices;
switch (choices)
{
case '1':
obj.login();
break;
case '2':
obj.signup();
break;
case '3':
obj.forgetpassword();
break;
case '4':
return 0;
default:
cout<<"envalid option";
}
return 0;
}
void temp ::signup(){
cout<<"enter your name ::";
getline(cin,username);
cout<<"enter your email::";
getline (cin,email);
cout<<"enter your password";
getline(cin,password);
file.open("logindata.txt",ios::out| ios::app);
file<<username<<" *"<<email<<" *"<<password<<endl;
file.close();
}
void temp :: login(){
string searchname, searchpass;
cout<<" ------LOGIN------ "<<endl;
cout<<"enter you user name:"<<endl;
getline(cin,searchname);
cout<<"enter your password:"<<endl;
getline(cin,searchpass);
file.open("logindata.txt",ios ::in);
getline(file,username,'*');
getline(file,email,'*');
getline(file,password,'\n');
while(!file.eof()){
if(username==searchname){
if(password==searchpass){
cout<<"\n you are sucessfully login....";
cout<<"\n your username ::"<<username;
cout<<"\n your email ::"<<email;
}
else{
cout<<"password is in correct";
}
}
getline(file,username,'*');
getline(file,email,'*');
getline(file,password,'\n');
}
file.close();
}
void temp :: forgetpassword(){
cout<<"\n enter your username ::";
getline(cin,searchname);
cout<<"\n enter your email::";
getline (cin,searchemail);
file.open("logindata.txt",ios :: in);
getline(file,username ,'*');
getline(file,email ,'*');
getline(file, password,'\n');
while (!file.eof()){
if(username == searchname)
if(email == searchemail){
cout<<"account found ";
cout<<" your password "<<password<<endl;
}
else{
cout<<"record not found";
}
else{
cout<<" not found";
}
}
file.close();
}
Comments
Post a Comment
welcome user , hope you good