___________________________________________________________________________________________________________
Login Form By Using Simple Codes
___________________________________________________________________________________________________________
In This Article I Will Tell You That How You Make a Login Form By Using C and C ++ Codes -->
- Login Form by Using C Programming -->
#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 -->
#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
-------------------------------------------------------------------------------------------------
0 Comments