Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using MySql;
- using MySql.Data.Common;
- using MySql.Data.MySqlClient;
- namespace Cheat_Admin_Menu
- {
- public partial class Form2 : Form
- {
- private String conn;
- private MySqlConnection connect;
- public Form2()
- {
- InitializeComponent();
- }
- private void db_connection()
- {
- try
- {
- conn = "Server=localhost;Database=YOURDATABASENAME;Uid=root;Password=DATABASEPASSWORD;";
- connect = new MySqlConnection(conn);
- connect.Open();
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private bool validate_login(string user, string pass)
- {
- db_connection();
- MySqlCommand cmd = new MySqlCommand();
- cmd.CommandText = "SELECT * FROM tewni where user_name = '" + textBox1.Text + "' and password = '" + textBox2.Text + "' ";
- cmd.Connection = connect;
- MySqlDataReader login = cmd.ExecuteReader();
- if(login.Read())
- {
- connect.Close();
- return true;
- }
- else
- {
- connect.Close();
- return false;
- }
- }
- private void Form2_Load(object sender, EventArgs e)
- {
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- string user = textBox1.Text;
- string pass = textBox2.Text;
- if (user == "" || pass == "")
- {
- MessageBox.Show("Please enter Your username and password");
- return;
- }
- bool r = validate_login(user, pass);
- if(r)
- {
- MessageBox.Show("logged in, Welcome " + user + "!");
- Form1 fo = new Form1();
- fo.Show();
- }
- else
- {
- MessageBox.Show("Please enter correct username and password", "Incorrect");
- }
- }
- catch(Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void Label3_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- MessageBox.Show("Your passoword is: *******", "Lost my password");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement