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.Data.Entity;
- using MySql.Data.MySqlClient;
- namespace chatt_client
- {
- public partial class loginWindow : Form
- {
- //SQL stuff
- string sqlConnString;
- string commandString;
- MySqlConnection sqlConnection;
- MySqlCommand cmd;
- MySqlDataReader sqlReader;
- //Login-related variables
- string username;
- string password;
- string id;
- public loginWindow()
- {
- sqlConnString = "server=localhost; database=chitchat; user=root; password=onRLlT2Z7X54eOeO;";
- InitializeComponent();
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- username = usernameText.Text;
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- password = passwordText.Text;
- }
- private void loginButton_Click(object sender, EventArgs e)
- {
- sqlConnection = new MySqlConnection(sqlConnString);
- sqlConnection.Open();
- commandString = "SELECT member_id from users where username = '" + username + "' and password = '" + password + "'";
- cmd = new MySqlCommand(commandString, sqlConnection);
- sqlReader = cmd.ExecuteReader();
- while (sqlReader.Read())
- {
- if (sqlReader["member_id"] != "0" && sqlReader["member_id"] != null)
- {
- this.Hide();
- id = Convert.ToString(sqlReader["member_id"]);
- var newChatWindow = new chatWindow(id);
- newChatWindow.Closed += (s, args) => this.Close();
- newChatWindow.Show();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement