JezK
Edit File: change_password.php
<?php include('menuheader.php'); $school_id=$_SESSION['child']['log_school_id']; //school_id $academic_id=$_SESSION['child']['current_academic_id'];// academic_year_id $user_id=$_SESSION['child']['auth_id']; //user_id $auth_email=$operations->get_authentication_email($user_id); $auth_pass =$operations->get_authentication_pass($user_id); $pwd=$operations->decryptIt($auth_pass); if(isset($_POST['submit'])) { $email=$_POST['email']; $current_password=$_POST['currentpass']; $new_password=$_POST['newpassword']; $conform_password=$_POST['conform']; $change_password=$operations->schooladmin_settings_change_password($user_id,$current_password,$new_password,$school_id); if($change_password) { if($change_password==1) { echo "<script>alert('Password updated successfully');</script>"; } else if($change_password==2) { echo "<script>alert('Password update failed');</script>"; } else if($change_password==3) { echo "<script>alert('Invalid Credentials');</script>"; } } } ?> <script> function validation() { $("#err_current").text(''); $("#err_new").text(''); $("#err_cnew").text(''); var curpass=document.getElementById('currentpass').value; var newpass=document.getElementById('newpassword').value; var conformpass=document.getElementById('conform').value; //var r=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[\@\#\$\%\^\&\*\!]).{7,}$/; var pcorrect=document.getElementById('pass_status').value; if(curpass=='') { $("#err_current").text('Please enter Password'); $("#err_current").show(); document.getElementById('currentpass').focus(); return false; } else if(pcorrect==1) { $("#err_current").text('Please enter a valid Current Password'); $("#err_current").show(); document.getElementById('currentpass').focus(); return false; } else if(newpass=='') { $("#err_new").text('Please enter New Password'); $("#err_new").show(); document.getElementById('newpassword').focus(); return false; } else if(newpass.length<6) { $("#err_new").text('Password does not meet the password criteria, Please try another Password'); $("#err_new").show(); document.getElementById('newpassword').focus(); return false; } //else if(!r.test(newpass)) //{ // $("#err_new").text('Password does not meet the password criteria, Please try another Password'); // $("#err_new").show(); // document.getElementById('newpassword').focus(); // return false; //} else if(conformpass=='') { $("#err_cnew").text('Please enter Confirm Password'); $("#err_cnew").show(); document.getElementById('conform').focus(); return false; } else if(conformpass != newpass) { $("#err_cnew").text('New Password and Confirm Password do not match'); $("#err_cnew").show(); document.getElementById('conform').focus(); return false; } } function checkpassword(uid,pass) { if(pass == '') { $("#err_current").text('Please enter Password'); $("#err_current").show(); document.getElementById('currentpass').focus(); return false; } else { $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"check_password"+"&pass="+pass+"&user="+uid, success: function(result) { if(result != pass) { $("#err_new").text(""); $("#err_cnew").text(""); $("#err_current").text('Please enter a valid Current Password'); $("#err_current").show(); document.getElementById('currentpass').focus(); document.getElementById('pass_status').value = "1"; return false; } else { $("#err_current").text(""); document.getElementById('pass_status').value = "0"; } } }); } } </script> <html> <body> <div class="row" style="margin-top:30px; margin-bottom:30px;"> <div class="col-md-9 text-left " style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:24px;"> <i class=" glyphicon glyphicon-wrench" title ="Change Password" style="font-size:20px;margin: 0px 0px 0px 21px;"></i> Change Password </div> </div> <form class="form-horizontal" method="post" action=""> <div class="box-body" style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; "> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-5 col-md-offset-1 text-right "> <b style="color:#666666;">User Name</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-6"> <input type="text" class="form-control" id="email" name="email" style="height:29px;font-size:13px; width:300px!important;" tabindex="1" value="<?php echo $auth_email;?>" readonly > </div> </div> </div> <div style="clear:both;"></div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-5 col-md-offset-1 text-right "> <b style="color:#666666;">Current Password</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-6"> <input type="password" class="form-control" id="currentpass" name="currentpass" style="height:29px;font-size:13px; width:300px!important;" tabindex="2" autocomplete="off" onblur="checkpassword(<?php echo $user_id;?>,this.value);"> <!-- if there is an error--> <div class="col-md-12" id="err_current" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> <div style="clear:both;"></div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-5 col-md-offset-1 text-right "> <b style="color:#666666;">New Password</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-6"> <input type="password" class="form-control" id="newpassword" name="newpassword" style="height:29px;font-size:13px; width:300px!important;" tabindex="3" value="" > <p><i>(minimum length is 6 characters)</i></p> <!-- if there is an error--> <div class="col-md-12" id="err_new" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> <div style="clear:both;"></div> <div class="clear"> <div class="form-group col-md-6" style="margin-bottom:1.0%;"> <div class="col-md-5 col-md-offset-1 text-right "> <b style="color:#666666;">Confirm Password</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-6"> <input type="password" class="form-control" id="conform" name="conform" style="height:29px;font-size:13px; width:300px!important;" tabindex="4" value="" > <!-- if there is an error--> <div class="col-md-12" id="err_cnew" style="color:#990000;margin-left:-15px;"></div> <!--- end error--> </div> </div> </div> </div> <div class="form-group"> <input type="hidden" name="pass_status" id="pass_status" value='0'> <div class="col-md-9" align="center"> <input type="submit" onclick= " return validation()" name="submit" class="btn btn-default custom-button-width .navbar-right btnclr" tabindex="19" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:20px; " value="Update" > <button type="button" class="btn btn-default custom-button-width .navbar-right btnclr" tabindex="20" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:20px; " onclick="location.href='dashboard.php'" >Cancel</button> </div> </div> </form> </body> </html>