Advertisement
IhateMyLife123

Untitled

Apr 14th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MySql;
  11. using MySql.Data.Common;
  12. using MySql.Data.MySqlClient;
  13.  
  14. namespace Cheat_Admin_Menu
  15. {
  16. public partial class Form2 : Form
  17. {
  18. private String conn;
  19. private MySqlConnection connect;
  20.  
  21. public Form2()
  22. {
  23. InitializeComponent();
  24. }
  25.  
  26. private void db_connection()
  27. {
  28. try
  29. {
  30. conn = "Server=localhost;Database=YOURDATABASENAME;Uid=root;Password=DATABASEPASSWORD;";
  31. connect = new MySqlConnection(conn);
  32. connect.Open();
  33. }
  34. catch(Exception ex)
  35. {
  36. MessageBox.Show(ex.Message);
  37. }
  38.  
  39. }
  40. private bool validate_login(string user, string pass)
  41. {
  42. db_connection();
  43. MySqlCommand cmd = new MySqlCommand();
  44. cmd.CommandText = "SELECT * FROM tewni where user_name = '" + textBox1.Text + "' and password = '" + textBox2.Text + "' ";
  45. cmd.Connection = connect;
  46. MySqlDataReader login = cmd.ExecuteReader();
  47. if(login.Read())
  48. {
  49. connect.Close();
  50. return true;
  51. }
  52. else
  53. {
  54. connect.Close();
  55. return false;
  56. }
  57. }
  58.  
  59. private void Form2_Load(object sender, EventArgs e)
  60. {
  61.  
  62. }
  63.  
  64. private void Button1_Click(object sender, EventArgs e)
  65. {
  66.  
  67. try
  68. {
  69. string user = textBox1.Text;
  70. string pass = textBox2.Text;
  71.  
  72. if (user == "" || pass == "")
  73. {
  74. MessageBox.Show("Please enter Your username and password");
  75. return;
  76. }
  77. bool r = validate_login(user, pass);
  78. if(r)
  79. {
  80. MessageBox.Show("logged in, Welcome " + user + "!");
  81.  
  82. Form1 fo = new Form1();
  83. fo.Show();
  84.  
  85. }
  86. else
  87. {
  88. MessageBox.Show("Please enter correct username and password", "Incorrect");
  89. }
  90. }
  91. catch(Exception ex)
  92. {
  93. MessageBox.Show(ex.Message);
  94. }
  95. }
  96.  
  97. private void Label3_Click(object sender, EventArgs e)
  98. {
  99. this.Close();
  100. }
  101.  
  102. private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  103. {
  104. MessageBox.Show("Your passoword is: *******", "Lost my password");
  105. }
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement