JezK
Edit File: Change_Password.php
<?php include('session_check.php'); include('sa_operations.php'); $operation=new sa_operations(); $res=$_SESSION['master']['auth']; $res1=$_SESSION['master']['me_id']; $auth_email=$operation->get_authentication_email($res1); if(isset($_POST['submit'])) { $email=$_POST['email']; $current_password=$_POST['currentpass']; $new_password=$_POST['newpassword']; $conform_password=$_POST['conform']; $change_password=$operation->superadmin_settigs_change_password($email,$current_password,$new_password); if($change_password) { if($change_password==2) { echo "<script>alert('Password update failed');</script>"; } else if($change_password==3) { echo "<script>alert('Invalid Credentials');</script>"; } } } include('header.php');?> <script> function validation() { $('#err_conform').text(""); $('#err_currentpass').text(""); $('#err_newpassword').text(""); var pass_status = document.getElementById('pass_status').value; 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,}$/; if(curpass=="") { $('#err_currentpass').text("Please enter Password"); $('#err_currentpass').show(); return false; } else if(pass_status==1) { $('#err_currentpass').text("Please enter a valid Current Password"); $('#err_currentpass').show(); return false; } else if(newpass=="") { $('#err_newpassword').text("Please enter New Password"); $('#err_newpassword').show(); return false; } else if(!r.test(newpass)) { $('#err_newpassword').text("Password does not meet the password criteria, Please try another Password"); $('#err_newpassword').show(); return false; } else if(conformpass=="") { $('#err_conform').text("Please enter Confirm Password"); $('#err_conform').show(); return false; } else if(newpass!=conformpass) { $('#err_conform').text("New Password and Confirm Password do not match"); $('#err_conform').show(); document.getElementById('conform').value=""; document.getElementById('conform').focus(); return false; } } function check_pass(pass,uid) { var curpass=document.getElementById('currentpass').value; $('#err_currentpass').text(""); $('#err_newpassword').text(""); if(curpass == '') { $("#err_currentpass").text('Please enter Password'); $("#err_currentpass").show(); document.getElementById('currentpass').focus(); return false; } else { $.ajax({ url: "ajaxcalls.php", type:"POST", data:"mode="+"check_admin_password"+"&pass="+pass+"&user="+uid, success: function(result) { if(result != pass) { $("#err_currentpass").text('Please enter a valid Current Password'); $("#err_currentpass").show(); document.getElementById('currentpass').focus(); document.getElementById('pass_status').value = "1"; return false; } else { $("#err_currentpass").hide(); document.getElementById('pass_status').value = "0"; } } }); } } </script> <html> <body style="overflow-x: hidden;"> <div class="row" style="margin-top:30px; margin-bottom:30px;"> <div class="col-md-3 " style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:14px; color:#000000; font-size:1.4em; padding-left:20px; margin-left:30px;"> <i class=" glyphicon glyphicon-wrench" title ="Change Password" style="font-size: 16px;"></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;">Email Id</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['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;" onblur="check_pass(this.value,'<?=$res1?>')" tabindex="2" autocomplete="off" > <!-- if there is an error--> <div class="col-md-12" id="err_currentpass" style="color:#990000;margin-left:-15px; display:none;"></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>(One Upper Case, One Lower Case, One digit, One special character out of !,@,#,$,%,^.&,* and minimum length is 7 characters)</i></p> <!-- if there is an error--> <div class="col-md-12" id="err_newpassword" style="color:#990000;margin-left:-15px; display:none;"></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_conform" style="color:#990000;margin-left:-15px; display:none;"></div> <!--- end error--> </div> </div> </div> </div> <input type="hidden" name="pass_status" id="pass_status" value='0'> <div class="form-group"> <div class="col-md-9" align="center"> <input type="submit" onclick="return validation()" name="submit" class="btn btn-default custom-button-width .navbar-right" 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" tabindex="20" style="font-family:Arial, Helvetica, sans-serif;font-style:normal;font-size:13px; margin:20px; " onclick="location.href='schoolmanagement.php'" >Cancel</button> </div> </div> </form> </body> </html>