Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Pls Provide me business logic method for reset password or forget password by user id...

Pls Provide me business logic method for reset password or forget password by user id...

Scheduled Pinned Locked Moved ASP.NET
business
16 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U User 13642228

    Pls Provide me business logic method for reset password or forget password by user id...

    M Offline
    M Offline
    Mukthahar Shaik
    wrote on last edited by
    #5

    in order to reset password you have to give email link or else you can give direct web page link. before reset password. you should take email address from the user. so you can use in where clause. see my code:

      protected void save\_Click(object sender, EventArgs e)
    {
        if (password.Text != "" || confirmpassword.Text != "")
        {
            if (password.Text == confirmpassword.Text)
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("update login set password='" + password.Text + "', confirmpassword='" + confirmpassword.Text + "' where email='" + Session\["email"\] + "'", con);
                cmd.ExecuteNonQuery();
                con.Close();
                Label1.Text = "Password Reset Successfully";
                HtmlMeta meta = new HtmlMeta();
                meta.HttpEquiv = "Refresh";
                meta.Content = "5;url=loginuser.aspx";
                this.Page.Controls.Add(meta);
            }
            else
                Label1.Text = "Password not Matched";
        }
        else
            Label1.Text="Please Enter Password";
    }
    

    ask email or username. then display password reset webpage. use email or username in where clause to update password.

    if you want id then use sql query like

    select id from userDetails where email=session["email"];

    i hope you will understand.

    U L P Richard DeemingR 4 Replies Last reply
    0
    • M Mukthahar Shaik

      in order to reset password you have to give email link or else you can give direct web page link. before reset password. you should take email address from the user. so you can use in where clause. see my code:

        protected void save\_Click(object sender, EventArgs e)
      {
          if (password.Text != "" || confirmpassword.Text != "")
          {
              if (password.Text == confirmpassword.Text)
              {
                  con.Open();
                  SqlCommand cmd = new SqlCommand("update login set password='" + password.Text + "', confirmpassword='" + confirmpassword.Text + "' where email='" + Session\["email"\] + "'", con);
                  cmd.ExecuteNonQuery();
                  con.Close();
                  Label1.Text = "Password Reset Successfully";
                  HtmlMeta meta = new HtmlMeta();
                  meta.HttpEquiv = "Refresh";
                  meta.Content = "5;url=loginuser.aspx";
                  this.Page.Controls.Add(meta);
              }
              else
                  Label1.Text = "Password not Matched";
          }
          else
              Label1.Text="Please Enter Password";
      }
      

      ask email or username. then display password reset webpage. use email or username in where clause to update password.

      if you want id then use sql query like

      select id from userDetails where email=session["email"];

      i hope you will understand.

      U Offline
      U Offline
      User 13642228
      wrote on last edited by
      #6

      thanks, Ya I understood... you have well explained!😊

      M L 2 Replies Last reply
      0
      • U User 13642228

        thanks, Ya I understood... you have well explained!😊

        M Offline
        M Offline
        Mukthahar Shaik
        wrote on last edited by
        #7

        you are welcome

        1 Reply Last reply
        0
        • M Mukthahar Shaik

          in order to reset password you have to give email link or else you can give direct web page link. before reset password. you should take email address from the user. so you can use in where clause. see my code:

            protected void save\_Click(object sender, EventArgs e)
          {
              if (password.Text != "" || confirmpassword.Text != "")
              {
                  if (password.Text == confirmpassword.Text)
                  {
                      con.Open();
                      SqlCommand cmd = new SqlCommand("update login set password='" + password.Text + "', confirmpassword='" + confirmpassword.Text + "' where email='" + Session\["email"\] + "'", con);
                      cmd.ExecuteNonQuery();
                      con.Close();
                      Label1.Text = "Password Reset Successfully";
                      HtmlMeta meta = new HtmlMeta();
                      meta.HttpEquiv = "Refresh";
                      meta.Content = "5;url=loginuser.aspx";
                      this.Page.Controls.Add(meta);
                  }
                  else
                      Label1.Text = "Password not Matched";
              }
              else
                  Label1.Text="Please Enter Password";
          }
          

          ask email or username. then display password reset webpage. use email or username in where clause to update password.

          if you want id then use sql query like

          select id from userDetails where email=session["email"];

          i hope you will understand.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #8

          Everything about that is just so wrong.

          M 1 Reply Last reply
          0
          • U User 13642228

            thanks, Ya I understood... you have well explained!😊

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #9

            ... and if you follow that advice your entire system is open to every hacker in the world.

            M 1 Reply Last reply
            0
            • L Lost User

              Everything about that is just so wrong.

              M Offline
              M Offline
              Mukthahar Shaik
              wrote on last edited by
              #10

              yes you are Richard. always use parameterized query.But i used this code for my college project. so i wrote like this. my suggestion also. go with parameterized query to protect from sql injection.

              1 Reply Last reply
              0
              • M Mukthahar Shaik

                in order to reset password you have to give email link or else you can give direct web page link. before reset password. you should take email address from the user. so you can use in where clause. see my code:

                  protected void save\_Click(object sender, EventArgs e)
                {
                    if (password.Text != "" || confirmpassword.Text != "")
                    {
                        if (password.Text == confirmpassword.Text)
                        {
                            con.Open();
                            SqlCommand cmd = new SqlCommand("update login set password='" + password.Text + "', confirmpassword='" + confirmpassword.Text + "' where email='" + Session\["email"\] + "'", con);
                            cmd.ExecuteNonQuery();
                            con.Close();
                            Label1.Text = "Password Reset Successfully";
                            HtmlMeta meta = new HtmlMeta();
                            meta.HttpEquiv = "Refresh";
                            meta.Content = "5;url=loginuser.aspx";
                            this.Page.Controls.Add(meta);
                        }
                        else
                            Label1.Text = "Password not Matched";
                    }
                    else
                        Label1.Text="Please Enter Password";
                }
                

                ask email or username. then display password reset webpage. use email or username in where clause to update password.

                if you want id then use sql query like

                select id from userDetails where email=session["email"];

                i hope you will understand.

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #11

                Please tell me you know why this is wrong. Have a read up about subjects like SQL injection and security best practices.

                This space for rent

                1 Reply Last reply
                0
                • L Lost User

                  ... and if you follow that advice your entire system is open to every hacker in the world.

                  M Offline
                  M Offline
                  Mukthahar Shaik
                  wrote on last edited by
                  #12

                  yes you are right Richard.

                  always use parameterized query. i used this code for my college project. so i wrote like this. my suggestion also go with parameterized query to protect from sql injection.

                  L 1 Reply Last reply
                  0
                  • M Mukthahar Shaik

                    yes you are right Richard.

                    always use parameterized query. i used this code for my college project. so i wrote like this. my suggestion also go with parameterized query to protect from sql injection.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #13

                    And you are also storing passwords in clear text, one of the most dangerous things to do. It does not matter that you are doing this as a college project. Do it right first time and you are less likely to fall into these traps when you are doing it for real. Quite frankly if you offered that as a sample of your work in a job interview you would be discounted immediately.

                    U 1 Reply Last reply
                    0
                    • M Mukthahar Shaik

                      in order to reset password you have to give email link or else you can give direct web page link. before reset password. you should take email address from the user. so you can use in where clause. see my code:

                        protected void save\_Click(object sender, EventArgs e)
                      {
                          if (password.Text != "" || confirmpassword.Text != "")
                          {
                              if (password.Text == confirmpassword.Text)
                              {
                                  con.Open();
                                  SqlCommand cmd = new SqlCommand("update login set password='" + password.Text + "', confirmpassword='" + confirmpassword.Text + "' where email='" + Session\["email"\] + "'", con);
                                  cmd.ExecuteNonQuery();
                                  con.Close();
                                  Label1.Text = "Password Reset Successfully";
                                  HtmlMeta meta = new HtmlMeta();
                                  meta.HttpEquiv = "Refresh";
                                  meta.Content = "5;url=loginuser.aspx";
                                  this.Page.Controls.Add(meta);
                              }
                              else
                                  Label1.Text = "Password not Matched";
                          }
                          else
                              Label1.Text="Please Enter Password";
                      }
                      

                      ask email or username. then display password reset webpage. use email or username in where clause to update password.

                      if you want id then use sql query like

                      select id from userDetails where email=session["email"];

                      i hope you will understand.

                      Richard DeemingR Offline
                      Richard DeemingR Offline
                      Richard Deeming
                      wrote on last edited by
                      #14

                      Let's see: SQL Injection. Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^] How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^] Query Parameterization Cheat Sheet | OWASP[^] Storing passwords as plain text. Secure Password Authentication Explained Simply[^] Salted Password Hashing - Doing it Right[^] Letting anyone reset any password just by providing an email address. And probably several other severe security vulnerabilities which I haven't immediately spotted. Don't do it like this - not even for a simple demo or college project. Troy Hunt: Everything you ever wanted to know about building a secure password reset feature[^]


                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                      1 Reply Last reply
                      0
                      • U User 13642228

                        Pls Provide me business logic method for reset password or forget password by user id...

                        Richard DeemingR Offline
                        Richard DeemingR Offline
                        Richard Deeming
                        wrote on last edited by
                        #15

                        Troy Hunt: Everything you ever wanted to know about building a secure password reset feature[^]


                        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                        1 Reply Last reply
                        0
                        • L Lost User

                          And you are also storing passwords in clear text, one of the most dangerous things to do. It does not matter that you are doing this as a college project. Do it right first time and you are less likely to fall into these traps when you are doing it for real. Quite frankly if you offered that as a sample of your work in a job interview you would be discounted immediately.

                          U Offline
                          U Offline
                          User 13642228
                          wrote on last edited by
                          #16

                          Ya Kind of it make sense...

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups