Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <authentication mode="Forms">
- <forms loginUrl="~/Login.aspx" timeout="2880" defaultUrl="~/" />
- </authentication>
- <authorization>
- <deny users="?"/>
- </authorization>
- protected void btnSubmit_Click(object sender, EventArgs e)
- {
- String LoginID = txtUsername.Text.Trim().ToLower();
- String LoginPassword = txtPassword.Text.Trim();
- SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString);
- conn.Open();
- SqlCommand cmd = new SqlCommand("select username,password,usertype from tbl_User where username =@username and password=@password and Active= 1 ", conn);
- cmd.Parameters.AddWithValue("@username", txtUsername.Text);
- cmd.Parameters.AddWithValue("@password", txtPassword.Text);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- DataTable dt = new DataTable();
- da.Fill(dt);
- if (dt != null && dt.Rows.Count > 0)
- {
- if (dt.Rows[0]["usertype"].ToString() == "0") //SuperAdmin
- {
- Session["User"] = "0";
- Response.Redirect("csrpage.aspx");
- }
- else if (dt.Rows[0]["usertype"].ToString() == "1") // Admin
- {
- Session["User"] = "1";
- Response.Redirect("Admin.aspx");
- }
- else if (dt.Rows[0]["usertype"].ToString() == "2") // User
- {
- Session["User"] = "2";
- Response.Redirect("User.aspx");
- }
- }
- else
- {
- ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username and Password')</script>");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement