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.Windows.Forms;
- using System.Net.Sockets;
- using System.Data.Odbc;
- using MySql.Data.MySqlClient;
- namespace Client
- {
- public partial class Login : Form
- {
- private MySqlConnection Connection = new MySqlConnection("Database=aevitas_client; Data Source=aevitas.in; User Id=aevitas_arfa; Password=Z|*Z=XbVIwzj");
- private string readername = "aevitas_arfa";
- private string readerpass = "Z|*Z=XbVIwzj";
- private string x, y;
- public Login()
- {
- InitializeComponent();
- }
- private void lbl_Exit_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void Signin(string username, string password, string token)
- {
- }
- private void Login_Load(object sender, EventArgs e)
- {
- lbl_Loading.Visible = false;
- }
- private void ErrorBox(string Error)
- {
- MessageBox.Show(Error,"Oops..",MessageBoxButtons.OK,MessageBoxIcon.Information,MessageBoxDefaultButton.Button1);
- }
- private void btn_Signin_Click(object sender, EventArgs e)
- {
- lbl_Loading.Visible = true;
- // Check if all fields have been entered.
- if (txt_Password.Text == "")
- {
- ErrorBox("Please enter your password.");
- lbl_Loading.Visible = false;
- return;
- }
- if (txt_Username.Text == "")
- {
- ErrorBox("Please enter your username.");
- lbl_Loading.Visible = false;
- return;
- }
- // Actually log in.
- MySqlCommand command = Connection.CreateCommand();
- MySqlDataReader Reader;
- command.CommandText = "SELECT username FROM users WHERE username=" + txt_Username.Text + " AND password="+ txt_Password.Text;
- ErrorBox(Connection.DataSource + Connection.State);
- Connection.Open();
- Reader = command.ExecuteReader();
- while (Reader.Read())
- {
- x = Reader.GetValue(Reader.GetOrdinal("username")).ToString();
- y = Reader.GetValue(Reader.GetOrdinal("password")).ToString();
- }
- if (txt_Username.Text == x && txt_Username.Text == y)
- {
- ErrorBox("Server has accepted your login request.");
- }
- else
- {
- ErrorBox("Server has refused your login request.");
- }
- Connection.Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment