Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using MySql.Data.MySqlClient;
  7. using MySql.Data;
  8.  
  9. namespace epd_online
  10. {
  11.     class Program
  12.     {
  13.         public enum Options { goed, fout, onbekend };
  14.         static public Boolean Sessie;
  15.         static public string userName, passWord;
  16.         static void Main(string[] args)
  17.         {
  18.             Boolean login = false;
  19.  
  20.  
  21.  
  22.  
  23.             /* delete query */
  24.  
  25.  
  26.             //cmd = new MySqlCommand(query, conn);
  27.             //reader = cmd.ExecuteReader();
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.             //cmd = new MySqlCommand(deleteQuery, conn);
  35.             //cmd.ExecuteReader();
  36.             /*query = "SELECT * FROM users";
  37.             cmd = new MySqlCommand(query, conn);
  38.             reader = cmd.ExecuteReader();
  39.             while (reader.Read())
  40.             {
  41.                 Console.WriteLine(reader.GetString("username"));
  42.             }
  43.             */
  44.             while(true){
  45.             Console.WriteLine("Wat is je gebruikersnaam?");
  46.             userName = Console.ReadLine();
  47.             Console.WriteLine("Wat is je password");
  48.             passWord = Console.ReadLine();
  49.             Console.ReadKey();
  50.  
  51.             if (Login())
  52.             {
  53.                 login = true;
  54.                 break;
  55.             }
  56.             Console.WriteLine("Inloggen is gelukt");
  57.         }
  58.  
  59.         }
  60.  
  61.         static public Boolean Login(string userName, string passWord)
  62.         {
  63.             MySqlCommand cmd;
  64.             MySqlDataReader reader = null;
  65.             DBclass DBclass = new DBclass();
  66.             MySqlConnection conn = DBclass.connect();
  67.             int rowCount;
  68.  
  69.  
  70.             string query = "SELECT * FROM users WHERE password='{0}' and username='{1}'", userName, passWord;
  71.  
  72.             cmd = new MySqlCommand(query, conn);
  73.             rowCount = (int)cmd.ExecuteScalar();
  74.             if (rowCount == 1)
  75.             {
  76.                 return Sessie = true;
  77.             }
  78.             else
  79.             {
  80.                 return Sessie = false;
  81.             }
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement