<%-- 

    Document   : index

    Created on : Oct 22, 2019, 7:24:44 AM

    Author     : DEEP

--%>



   <form action="code/changepasscode.jsp" method="post" onsubmit="return validation()">

                    

        

  Enter Old Password

<input type="Password" name="opass" class="form-control input-text" id="opass">

<span id="oldpass" style="color:red; font-weight:350;"> </span>

                

    Enter New Password

<input type="Password" name="npass" class="form-control input-text" id="npass">

 <span id="newpass" style="color:red; font-weight:350;"> </span>

                         

Enter Confirm Password:<span class="fa fa-lock"></span></td>

<input type="Password" name="cpass" class="form-control input-text" id="cpass">

<span id="confirmpass" style="color:red; font-weight:350;"> </span>


 <script>

  $(document).ready(function() {

  $('input[type=\'password\']').showHidePassword();

});

</script>

<script>

    function validation(){

        var oldpassord= document.getElementById('opass').value;

         var newpassword= document.getElementById('npass').value;

         var confirmpassword= document.getElementById('cpass').value;

        if(oldpassord==""){

            document.getElementById('oldpass').innerHTML="** Please enter the old password "

            return false;

        }

         if(newpassword==""){

            document.getElementById('newpass').innerHTML="** Please enter the new password "

            return false;

        }

        if((newpassword.length <= 5) || (newpassword.length > 15)){

            document.getElementById('newpass').innerHTML="** password length must between 5 and 15 "

            return false;

        }

        if(confirmpassword==""){

            document.getElementById('confirmpass').innerHTML="** Please enter the confirm new password "

            return false;

        }

        if(newpassword != confirmpassword){

            document.getElementById('pass1').innerHTML="**-----------------------Password does not match -----------------------** "

            return false;

        }

    }

</script>

 

--------------Code---------------




<%
String old,ne,con;
old=request.getParameter("opass");
ne=request.getParameter("npass");
con=request.getParameter("cpass");
DbManager db=new DbManager();
String cmd="update login set pass='"+ne+"' where name='admin' and pass='"+old+"'"; // and userid='"+email+"'";

boolean b=db.ExecuteInsertUpdateDelete(cmd);

    
    if(b==true)
    {
        out.print("<script>alert('Password Change Successfully..'); window.location.href='../changepass.jsp'</script>");
    }
    else{
   out.print("<script>alert('Password Not Change Successfully..'); window.location.href='../changepass.jsp'</script>");
    }


%>


-