Header Ads Widget

Ticker

6/recent/ticker-posts

How To Make Login Form By Using C and C ++ Codes || Simple Codes For Login Form || Login Page Kese Banaye ? By Ankit Singhal

___________________________________________________________________________________________________________

Login Form By Using Simple Codes 

___________________________________________________________________________________________________________


Login Form


 In This Article I Will Tell You That How You Make a Login Form By Using C and C ++ Codes -->

     ----------------------------------------

  1.  Login Form by Using C Programming -->

      ----------------------------------------

Login Form By Using C Simple Code
Login Form By Using C Simple Code



Simple C Code Given Below :-


#include <stdio.h>

#include <string.h>


int main ()

{

char id[50];

User:


printf("Enter your id:\n");

scanf("%s", &id);


if (strcmp(id,"ankit")==0)

{

printf("Id is correct\n");

}

else

{

printf("You have enetred an invalid user id\nPlease enter id again\n");

goto User;

}

char pass[50];

pass:

printf("Enter your password: ");

scanf("%s", &pass);


if(strcmp(pass,"ankit17")==0)

{

printf("You have successly loged in into G-Mail\n");

}

else

{

printf("You have entered a wrong password\nEnter your password again\n");

goto pass;

}


return 0;

}


   

      ------------------------------------------


     2. Login Form by Using C ++ Programming -->


      ------------------------------------------

Login Form By Using C ++ Simple Code
Login Form By Using C ++ Simple Code



Simple C ++ Code Given Below :-


#include <iostream>
using namespace std;
int main ()
{
    string userName;
    string userPassword;
    int loginAttempt = 0;
    while (loginAttempt < 5)
    {
        cout << "Please enter your user name: ";
        cin >> userName;
        cout << "Please enter your user password: ";
        cin >> userPassword;
        if (userName == "ankit" && userPassword == "ankit@17")
        {
            cout << "Welcome Ankit!\n";
            break;
        }
        else if (userName == "patrick" && userPassword == "dunn")
        {
            cout << "Welcome Patrick!\n";
            break;
        }
        else
        {
            cout << "Invalid login attempt. Please try again.\n" << '\n';
            loginAttempt++;
        }
    }
    if (loginAttempt == 5)
    {
            cout << "Too many login attempts! The program will now terminate.";
            return 0;
    }
    cout << "Thank you for logging in.\n";
}


-------------------------------------------------------------------------------------------------

Thanks For Visiting My Article

-------------------------------------------------------------------------------------------------


if You Like My Content Then Please Comment Down 

Post a Comment

0 Comments