Thursday, November 17, 2022

Login And Registration Program

Login Page using C++


CODE:



#include<iostream.h>
#include<conio.h>
#include<string.h>

class login
{
    private:
    int c,j;

    char u_name[15][20],pass[15][20];

    public:
    login()
    {
        c=0;
        j=0;
    }

    void Register()
    {
        char a[20];
        int d,z;
        for(;j<=c;j++)
        {
        cout<<"\nCreating New Account....";
        cout<<"\nEnter Username = ";
        cin>>a;
        for(int k=0;k<c;k++)
        {
            d=strcmp(u_name[k],a);
            if(d==0)
            {
                z=4;
                break;
               
            }
        }
        if(z==4)
        {
            cout<<"Entered UserName Already Exist";
            c--;
            j--;
        }
        else
        {
            strcpy(u_name[j],a);
            cout<<"\nEnter Password = ";
            cin>>pass[j];
        }
        }
        c++;

    }
    void log()
    {
        char user[20],upass[20];
        int l,d,f;
        cout<<"\nEnter Login Details....";
        cout<<"\nEnter Username: ";
        cin>>user;
        cout<<"\nEnter Password: ";
        cin>>upass;
        for(int i=0;i<c;i++)
        {
        l=strcmp(user,u_name[i]);
        d=strcmp(pass[i],upass);
        if(l==0 && d==0)
        {
        f=4;
        }
        }
        if(f==4)
        {
        cout<<"\n********************************\n";
        cout<<"\nWelcome, "<<user<<"\n";
        cout<<"\n********************************\n";
        }

        else
        {
        cout<<"\nInvalid Username or Password......";
        }

    }

    void showdata()
    {
        char p[20];
        int d;
        cout<<"\nEnter Secreate Pass : ";
        cin>>p;
        d=strcmpi(p,"Manav7045");
        cout<<"Data of all users: ";
        cout<<"\nUsername"<<"\tPassword\n";
        for(int i=0;i<c;i++)
        {
           if(d==0)
        {
        cout<<"\n"<<u_name[i]<<"\t\t"<<pass[i];
        }
        }
    }
};

void main()
{
    login n;
    int ch;

    do
    {
    cout<<"\n1: Register\n2: Login\n3: Database\n4:Exit";
    cout<<"\nEnter any Choice = ";
    cin>>ch;
    if (ch==1)
    {
        n.Register();
    }

    else if (ch==2)
    {
    n.log();
    }

    else if (ch==3)
    {
    n.showdata();

    }
    else if(ch==4)
    {
    cout<<"\nExiting The Program.....";
    break;
    }
    else
    {
    cout<<"\nWrong Entry.....\n";
    ch=0;
    }
    } while (ch!=4);

    getch();
}




OUTPUT:



No comments:

Post a Comment

Login And Registration Updated

OOP Microproject....... (Codeblocks is recommended to perform this Program) #include <iostream> #include <conio.h> #include <...