-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_pass_action.php
37 lines (36 loc) · 1.4 KB
/
change_pass_action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
session_start();
include "auth.php";
include "connection.php";
if(isset($_POST['cpass'])) {
$currentpass = md5($_POST['cpassword']) ;
$newpass = md5($_POST['npassword']);
$cnewpass = md5($_POST['cnpassword']);
$currentpass = addslashes($currentpass);
$newpass = addslashes($newpass);
$cnewpass = addslashes($cnewpass);
$currentpass = mysqli_real_escape_string($con, $currentpass);
$newpass = mysqli_real_escape_string($con, $newpass);
$cnewpass = mysqli_real_escape_string($con, $cnewpass);
$sql = mysqli_query($con, 'SELECT password FROM loginusers WHERE username="'.$_SESSION['SESS_NAME'].'" ');
$row = mysqli_fetch_assoc($sql);
$pass = $row['password'];
if ($currentpass != $pass) {
$error = "<center><h4><font color='#FF0000'>Incorrect Current Password!</h4></center></font>";
include ("change_pass.php");
}
else if ($currentpass == $pass && $newpass == $cnewpass){
$sql1 = mysqli_query($con, 'UPDATE loginusers SET password="'. md5($_POST['npassword']).'" WHERE username="'.$_SESSION['SESS_NAME'].'" ');
$error = "<center><h4><font color='green'>Password successfully changed!</h4></center></font>";
include ("change_pass.php");
}
else {
$error = "<center><h4><font color='#FF0000'>New Password and Confirm Password does not match!</h4></center></font>";
include ("change_pass.php");
}
}
else {
$error = "<center><h4><font color='#FF0000'>Error!</h4></center></font>";
include ("change_pass.php");
}
?>