Answer the question
In order to leave comments, you need to log in
How to make authorization in the program through the mysql database?
The task is
private void RegisterBtn_Click(object sender, EventArgs e)
{
this.Hide(); // Скрыть 1 форму
Register reg = new Register(); // Создать новую 2 форму
reg.ShowDialog(); // Отобразить форму
this.Close(); // Закрыть 1 форму
}
private void LoginBtn_Click(object sender, EventArgs e)
{
string CommandText = "SELECT * FROM users WHERE Username= " + LoginBox.Text + " AND password = " + PassBox.Text + " LIMIT 1";
string Connect = "Database=kbecker;Data Source=localhost;User Id=root;Password=";
SqlConnection myConnection = new SqlConnection(Connect);
SqlCommand myCommand = new SqlCommand(CommandText, myConnection);
myConnection.Open();
/*
Что тут писать если верно, или неверно
*/
myConnection.Close();
if (LoginBox.Text == "Anonymous" && PassBox.Text == "kgp193mdl250")
{
this.Hide();
Main fm = new Main();
fm.ShowDialog();
this.Close();
}
}
private void RememberCheck_CheckedChanged(object sender, EventArgs e)
{
if (RememberCheck.Checked == true)
{
LoginBox.Text = "Anonymous";
PassBox.Text = "kgp193mdl250";
}
else
{
LoginBox.Clear();
PassBox.Clear();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question