0% found this document useful (0 votes)
6 views2 pages

9 Question

Uploaded by

extra0848
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

9 Question

Uploaded by

extra0848
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Question 9 : Design a Login form using basic form controls with proper

validations in C# .Net(login credentials are stored in an array)

Program:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LoginFormSetup
{
public partial class Form1 : Form
{
string[] email = { "[email protected]", "[email protected]",
"[email protected]", "[email protected]" };
string[] password = { "Zaid@123", "Fahad@123", "Ali@123", "Abdul@123" };
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int check = 0;
string loggedinUser="";
for(int i=0;i<4;i++)
{
if(this.textBox1.Text == email[i] && this.textBox2.Text == password[i])
{
check++;
loggedinUser = email[i];
}
}
if (check == 0)
{
MessageBox.Show("Incorrect email or password");
}
else
{
MessageBox.Show(loggedinUser+" Welcome | You are Logged in");
}
}
}
}

1
outputs:

output if login credentials are wrong

output if login credentials are right and system show you are
logged in

You might also like