Guest User

Untitled

a guest
Jul 9th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 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.Windows.Forms;
  9. using System.Net.Sockets;
  10. using System.Data.Odbc;
  11. using MySql.Data.MySqlClient;
  12.  
  13. namespace Client
  14. {
  15. public partial class Login : Form
  16. {
  17. private MySqlConnection Connection = new MySqlConnection("Database=aevitas_client; Data Source=aevitas.in; User Id=aevitas_arfa; Password=Z|*Z=XbVIwzj");
  18. private string readername = "aevitas_arfa";
  19. private string readerpass = "Z|*Z=XbVIwzj";
  20. private string x, y;
  21.  
  22. public Login()
  23. {
  24. InitializeComponent();
  25. }
  26.  
  27. private void lbl_Exit_Click(object sender, EventArgs e)
  28. {
  29. Application.Exit();
  30. }
  31.  
  32. private void Signin(string username, string password, string token)
  33. {
  34. }
  35.  
  36. private void Login_Load(object sender, EventArgs e)
  37. {
  38. lbl_Loading.Visible = false;
  39. }
  40.  
  41. private void ErrorBox(string Error)
  42. {
  43. MessageBox.Show(Error,"Oops..",MessageBoxButtons.OK,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1);
  44. }
  45.  
  46. private void btn_Signin_Click(object sender, EventArgs e)
  47. {
  48. lbl_Loading.Visible = true;
  49.  
  50. // Check if all fields have been entered.
  51. if (txt_Password.Text == "")
  52. {
  53. ErrorBox("Please enter your password.");
  54. lbl_Loading.Visible = false;
  55. return;
  56. }
  57. if (txt_Username.Text == "")
  58. {
  59. ErrorBox("Please enter your username.");
  60. lbl_Loading.Visible = false;
  61. return;
  62. }
  63.  
  64. // Actually log in.
  65. MySqlCommand command = Connection.CreateCommand();
  66. MySqlDataReader Reader;
  67. command.CommandText = "SELECT username FROM users WHERE username=" + txt_Username.Text + " AND password="+ txt_Password.Text;
  68. ErrorBox(Connection.DataSource + Connection.State);
  69. Connection.Open();
  70. Reader = command.ExecuteReader();
  71. while (Reader.Read())
  72. {
  73. x = Reader.GetValue(Reader.GetOrdinal("username")).ToString();
  74. y = Reader.GetValue(Reader.GetOrdinal("password")).ToString();
  75. }
  76.  
  77. if (txt_Username.Text == x && txt_Username.Text == y)
  78. {
  79. ErrorBox("Server has accepted your login request.");
  80. }
  81. else
  82. {
  83. ErrorBox("Server has refused your login request.");
  84. }
  85. Connection.Close();
  86.  
  87. }
  88. }
  89. }
Add Comment
Please, Sign In to add comment