- Create procedure [dbo].[spLogin]
- (
- @Email nvarchar(50),
- @Password nvarchar(50)
- )
- as
- begin
- Select COUNT(*) from UserRegistration where Email=@Email and Password=@Password
- end
- ---------------------------------
- Clicking on Login button
- protected void btnLogin_Click(object sender, EventArgs e)
- {
- string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
- using (SqlConnection con=new SqlConnection(CS))
- {
- SqlCommand cmd = new SqlCommand("spLogin", con);
- cmd.CommandType = CommandType.StoredProcedure;
- con.Open();
- cmd.Parameters.AddWithValue("@Email",txtEmail.Text.Trim());
- cmd.Parameters.AddWithValue("@Password", Decrypt(txtPassword.Text.Trim()));
- int Username = (Int32)cmd.ExecuteScalar();
- if (Username == 1)
- {
- Session["Username"] = txtEmail.Text;
- Response.Redirect("Welcome.aspx");
- Session.RemoveAll();
- }
- else
- {
- lblMessage.ForeColor = System.Drawing.Color.Red;
- lblMessage.Text = "Invalid username and password";
- }
- }
- }
- reference:- https://www.c-sharpcorner.com/blogs/how-to-login-with-encrypted-password-in-asp-net
- https://www.c-sharpcorner.com/blogs/how-to-create-user-registration-form-with-encrypted-password-using-asp-net#ReadAndPostComment
No comments:
Post a Comment