private void button2_Click(object sender, EventArgs e)//try to log in { string email = emailTextBox.Text; string pass = passwordTextBox.Text; string connStr = "server=localhost;user=root;database=paswman;port=3306;password=''"; MySqlConnection conn = new MySqlConnection(connStr); try { conn.Open(); string sql = "SELECT NAME FROM users WHERE NAME='" + email + "' AND PASSWORD='******'"; MySqlCommand cmd = new MySqlCommand(sql, conn); object result = cmd.ExecuteScalar(); if (result != null) { Console.WriteLine("user is: " + result); DashBoard dashBoard = new DashBoard(result.ToString()); dashBoard.Show(); //this.Close(); this.Hide(); } else { MessageBox.Show("incorrect username or password"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } conn.Close(); }
private void deletePassword(object sender, EventArgs e, string name) { MySqlConnection conn = new MySqlConnection(connStr); try { conn.Open(); string sql = "DELETE FROM " + Username + " WHERE NAME = '" + name + "'"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader result = cmd.ExecuteReader(); if (result != null) { result.Read(); this.Refresh(); panel2.Controls.Clear(); panel1.Controls.Clear(); this.Close(); DashBoard dashBoard = new DashBoard(Username); dashBoard.Show(); Console.WriteLine("succesfull"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } conn.Close(); }
private void button1_Click(object sender, EventArgs e) { CreateNewPass createNewPass = new CreateNewPass(Username); createNewPass.ShowDialog(); this.Close(); DashBoard dashBoard = new DashBoard(Username); dashBoard.Show(); }
private void button1_Click(object sender, EventArgs e) { string username = textBox1.Text.ToString(); string password = textBox2.Text.ToString(); string check = textBox3.Text.ToString(); if (password.Equals(check) && !username.Equals("")) { MySqlConnection conn = new MySqlConnection(connStr); try { conn.Open(); string sql = "CREATE TABLE paswman." + username + " ( `ID` INT NOT NULL AUTO_INCREMENT, `NAME` TEXT NOT NULL , `PASSWORD` TEXT NOT NULL , PRIMARY KEY(`ID`)) ENGINE = InnoDB"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader result = cmd.ExecuteReader(); if (result != null) { while (result.Read()) { ; } //this.Close(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } conn.Close(); try { conn.Open(); string sql2 = "INSERT INTO users (`ID`, `NAME`, `PASSWORD`) VALUES (NULL, '" + username + "', '" + password + "')"; MySqlCommand cmd2 = new MySqlCommand(sql2, conn); MySqlDataReader result2 = cmd2.ExecuteReader(); if (result2 != null) { while (result2.Read()) { ; } DashBoard dash = new DashBoard(username); dash.Show(); this.Close(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }