private void registerLbl_Click(object sender, EventArgs e) { formLogin frmLogin = new formLogin(); this.Hide(); frmLogin.Show(); }
private void btnLogout_Click(object sender, EventArgs e) { this.Close(); formLogin frmLogin = new formLogin(); frmLogin.Show(); }
private void btnRegister_Click(object sender, EventArgs e) { if (txtEmail.Text == "" || txtFname.Text == "" || txtLname.Text == "" || txtPassword.Text == "" || txtEmail.Text == "email" || txtFname.Text == "first name" || txtLname.Text == "last name" || txtPassword.Text == "password" || comboDept.SelectedItem.ToString() == "" || comboSemester.SelectedItem.ToString() == "") { MessageBox.Show("Please enter all the fields"); } else { string email = txtEmail.Text.Trim(); string fname = txtFname.Text.Trim(); string lname = txtLname.Text.Trim(); string pw = txtPassword.Text; //int dept = comboDept.SelectedIndex; int dept = comboDept.SelectedIndex + 1; int semester = Int32.Parse(comboSemester.SelectedItem.ToString()); //MessageBox.Show("email: " + email + ", fname: " + fname + ", lname: " + lname + ", pw: " + pw + "deptid: " + dept + ", semester: " + semester); if (!IsValidEmail(email)) { MessageBox.Show("Enter a valid email address!"); } else { string myHash = BCrypt.HashPassword(pw, BCrypt.GenerateSalt()); MySqlConnection con = MySQLConnection.openCon(); string query = "INSERT INTO student (first_name, last_name, email, password, dept_id, photo, semester) VALUES('" + fname + "', '" + lname + "', '" + email + "', '" + myHash + "', " + dept + ", 'default.jpg', " + semester + ")"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.ExecuteNonQuery(); MessageBox.Show("Registered!"); formLogin frmLogin = new formLogin(); this.Hide(); frmLogin.Show(); } } }