Guest User

Untitled

a guest
Jun 14th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. using System.Web;
  2. using System.Web.UI;
  3. using System.Web.UI.WebControls;
  4. using System.Data.SqlClient;
  5. using System.Data;
  6. using System;
  7. using System.Configuration;
  8. using System.Text;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Xml.Linq;
  12.  
  13. public partial class Index : System.Web.UI.Page
  14. {
  15.  
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18. }
  19.  
  20. protected void BtnLogin_Click(object sender, EventArgs e)
  21. {
  22. SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Data Source=Server;Initial Catalog=DB;Integrated Security=True"].ConnectionString);
  23. conn.Open();
  24. string checkuser = "SELECT Username FROM USER WHERE Username='" + TextBoxUser.Text + "'";
  25. SqlCommand com = new SqlCommand(checkuser, conn);
  26. int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
  27. conn.Close();
  28. if (temp == 1)
  29. {
  30. conn.Open();
  31. string checkPasswordQuery = "SELECT Password FROM USER WHERE Password= '" + TextBoxPassword.Text + "'";
  32. SqlCommand passCom = new SqlCommand(checkPasswordQuery, conn);
  33. string password = passCom.ExecuteScalar().ToString().Replace(" ", "");
  34. if (password == TextBoxPassword.Text)
  35. {
  36. Session["New"] = TextBoxUser.Text;
  37. Response.Redirect("~/main.aspx");
  38. }
  39. else
  40. {
  41. Response.Redirect("~/password_in.aspx");
  42. }
  43. }
  44. else
  45. {
  46. Response.Redirect("~/password_in.aspx");
  47. }
  48. }
  49.  
  50. public class TextBoxUser
  51. {
  52. internal static string Text;
  53. }
  54.  
  55. public class TextBoxPassword
  56. {
  57. internal static string Text;
  58. }
  59. }
Add Comment
Please, Sign In to add comment