Advertisement
pretta118

LoggaIn.aspx.cs

Dec 14th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Configuration;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9.  
  10. namespace MyProject
  11. {
  12. public partial class BootstrapTutorial : System.Web.UI.Page
  13. {
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16.  
  17. //Logga in
  18. DBconnection newConnection = new DBconnection();
  19. newConnection.MyConnection();
  20.  
  21. string checkUser = "SELECT count(*) FROM Kund WHERE Anvandarnamn='" + txtAnvandarnamn.Text + "'";
  22. SqlCommand cmd = new SqlCommand(checkUser, DBconnection.conn);
  23.  
  24. int temp = Convert.ToInt32(cmd.ExecuteScalar().ToString());
  25. DBconnection.conn.Close();
  26.  
  27. if(temp == 1)
  28. {
  29. DBconnection.conn.Open();
  30. string checkPassword = "SELECT Losenord FROM Kund WHERE Anvandarnamn='" + txtAnvandarnamn.Text + "'";
  31. SqlCommand passCmd = new SqlCommand(checkPassword, DBconnection.conn);
  32. string password = passCmd.ExecuteScalar().ToString();
  33.  
  34. if(password == txtLosenord.Text)
  35. {
  36. Session["Anvandarnamn"] = txtAnvandarnamn.Text;
  37. Response.Redirect("Webshop.aspx");
  38.  
  39. }
  40. else
  41. {
  42. Response.Write("Lösenordet är inte korrekt!");
  43. }
  44. }
  45. else
  46. {
  47. Response.Write("Användarnamn är inte korrent!");
  48. }
  49. }
  50.  
  51. protected void Login_Click(object sender, EventArgs e)
  52. {
  53.  
  54. }
  55.  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement