-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-password.php
More file actions
51 lines (39 loc) · 1.13 KB
/
Copy pathupdate-password.php
File metadata and controls
51 lines (39 loc) · 1.13 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
session_start();
$old = $_POST['old'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$id = $_POST['update-passwords'];
include 'database.php';
$prev = mysqli_fetch_assoc(mysqli_query($con,"SELECT password FROM user WHERE id = '$id'"))['password'];
if(sha1($old) != $prev){
$_SESSION['alert']= 'Old Password Mismatched. Update Failed';
?>
<script type="text/javascript">
alert("Old Password Mismatched. Update Failed");
window.location.href ='profile.php';
</script>
<?php
}else if($password!= $password2){
$_SESSION['alert']= 'Confirm Password Mismatched. Update Failed';
?>
<script type="text/javascript">
alert("Confirm Password Mismatched. Update Failed");
window.location.href ='profile.php';
</script>
<?php
}
else{
$enc = sha1($password);
mysqli_query($con,"UPDATE user SET password = '$enc'
WHERE id = '$id'
");
$_SESSION['alert']= 'Password Updated';
?>
<script type="text/javascript">
alert("Password Updated");
window.location.href ='profile.php';
</script>
<?php
}
?>