C# с аутентификацией входа в систему XML
So I have this code to Authentic authenticate my user but it only loop through the first user and and other username it gives me wrong password or username. Any help please
Что я уже пробовал:
XmlDocument mac = new XmlDocument(); mac.Load(@"C:\Users\user\source\repos\lilis shop\lilis shop\Properties\XMLFile1.xml"); XmlNodeList xnlist = mac.SelectNodes("//users"); foreach (XmlNode naa in xnlist) { string username = naa["username"].InnerText; string password = naa["password"].InnerText; if (username == txtusername.Text && password == txtpassword.Text ) { Letsee = "LOGEDIN"; Form1 openform = new Form1(); openform.lablogin.Text = Letsee; openform.lab1.Text = this.txtusername.Text; openform.labelsingout.Text = "SINGOUT"; openform.Show(); this.Hide(); break; } else if (username != txtusername.Text) { MessageBox.Show("please enter the correct username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtpassword.Text = null; txtusername.Text = null; break; } else if (password != txtpassword.Text) { MessageBox.Show("please enter the correct password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtpassword.Text = null; txtusername.Text = null; break; } else { MessageBox.Show("please enter the correct password or username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtpassword.Text = null; txtusername.Text = null; break; }