내 프로젝트의 사용자 정의 로그인 페이지가 생성되었습니다. 사용자 로그인 자격 증명이 관리자 및 사용자에게 올바르게 작동하지 않습니다.
문제는 로그인이 Super Admin
부분에 대한 제대로 작동하는 것이 여기에 들어 관리자
2
들어 최고 관리자1
에 대한
0
아래에 다음과 같이 나는 역할을 부여했다. 하지만 관리자와 사용자를 만들어 해당 자격 증명으로 로그인하려고하면 사용자 이름이 유효하지 않습니다. &입니다. 확인하고 디버깅을 시도했지만 작동하지 않는 이유를 모르겠습니다.참조 용
Button_click
이벤트에 대한 코드를 참조하십시오 : -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 [email protected] and [email protected] and [email protected]", conn); cmd.Parameters.AddWithValue("@username", txtUsername.Text); cmd.Parameters.AddWithValue("@password", txtPassword.Text); cmd.Parameters.AddWithValue("@active", 1); 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"] = dt.Rows[0]["username"].ToString(); Response.Redirect("csrdashboards.aspx"); } else if (dt.Rows[0]["usertype"].ToString() == "1") // Admin { Session["User"] = dt.Rows[0]["username"].ToString(); Response.Redirect("csrdashboards.aspx"); } else if (dt.Rows[0]["usertype"].ToString() == "2") // User { Session["User"] = dt.Rows[0]["username"].ToString(); Response.Redirect("csrdashboards.aspx"); } } else { ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username and Password')</script>"); } }
이 도와주세요. 네가 다른 것을 필요로하면 알려줘.
관리자 및 사용자의 경우 null이 표시됩니까? – Neel
@ Neeel : 예 관리자와 함께 시도했을 때'null'이되었습니다. –
@ SonerGönül : 암호화 된 형식으로 저장 중입니다. –