Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MySql.Data.MySqlClient;
- using MySql.Data;
- namespace epd_online
- {
- class Program
- {
- public enum Options { goed, fout, onbekend };
- static public Boolean Sessie;
- static public string userName, passWord;
- static void Main(string[] args)
- {
- Boolean login = false;
- /* delete query */
- //cmd = new MySqlCommand(query, conn);
- //reader = cmd.ExecuteReader();
- //cmd = new MySqlCommand(deleteQuery, conn);
- //cmd.ExecuteReader();
- /*query = "SELECT * FROM users";
- cmd = new MySqlCommand(query, conn);
- reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- Console.WriteLine(reader.GetString("username"));
- }
- */
- while(true){
- Console.WriteLine("Wat is je gebruikersnaam?");
- userName = Console.ReadLine();
- Console.WriteLine("Wat is je password");
- passWord = Console.ReadLine();
- Console.ReadKey();
- if (Login())
- {
- login = true;
- break;
- }
- Console.WriteLine("Inloggen is gelukt");
- }
- }
- static public Boolean Login(string userName, string passWord)
- {
- MySqlCommand cmd;
- MySqlDataReader reader = null;
- DBclass DBclass = new DBclass();
- MySqlConnection conn = DBclass.connect();
- int rowCount;
- string query = "SELECT * FROM users WHERE password='{0}' and username='{1}'", userName, passWord;
- cmd = new MySqlCommand(query, conn);
- rowCount = (int)cmd.ExecuteScalar();
- if (rowCount == 1)
- {
- return Sessie = true;
- }
- else
- {
- return Sessie = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement