主题:用户登录页面代码
2、 用户登录页面代码:
msg_suc.Text = "";
//声明用户名数组
string[] Names = { "march", "rose", "blue", "六月", "蓝色精灵","bully" };
//声明密码数组
string[] Pwds = {"123456","43567y","mrry210","pwd7878","blue1314","worry" };
string UName = UserName.Text;
string UPwd = Pwd.Text;
//验证用户名和密码是否为空,如果为空则进行提示
if(UName=="")
{
msg_name.Text = "请输入用户名";
}
else if (UPwd == "")
{
msg_pwd.Text = "请输入密码";
}
else
{
msg_pwd.Text = "";
msg_name.Text = "";
//用户名与数组Names中的元素值进行比较
for (int i = 0; i < Names.Length; i++)
{
if (Names[i] == UName)
{
//验证密码是否正确
if (Pwds[i] == UPwd)
{
msg_suc.Text = "恭喜你!登录成功!";
}
else
{
msg_suc.Text = "密码不正确,请重新输入!";
}
break; //跳出循环
}
else
{
msg_suc.Text = "用户名不存在,请重新输入!";
}
}
}
信息来自[url]http://www.52benet.cn[/url]
msg_suc.Text = "";
//声明用户名数组
string[] Names = { "march", "rose", "blue", "六月", "蓝色精灵","bully" };
//声明密码数组
string[] Pwds = {"123456","43567y","mrry210","pwd7878","blue1314","worry" };
string UName = UserName.Text;
string UPwd = Pwd.Text;
//验证用户名和密码是否为空,如果为空则进行提示
if(UName=="")
{
msg_name.Text = "请输入用户名";
}
else if (UPwd == "")
{
msg_pwd.Text = "请输入密码";
}
else
{
msg_pwd.Text = "";
msg_name.Text = "";
//用户名与数组Names中的元素值进行比较
for (int i = 0; i < Names.Length; i++)
{
if (Names[i] == UName)
{
//验证密码是否正确
if (Pwds[i] == UPwd)
{
msg_suc.Text = "恭喜你!登录成功!";
}
else
{
msg_suc.Text = "密码不正确,请重新输入!";
}
break; //跳出循环
}
else
{
msg_suc.Text = "用户名不存在,请重新输入!";
}
}
}
信息来自[url]http://www.52benet.cn[/url]