-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchangePass.php
More file actions
30 lines (26 loc) · 874 Bytes
/
changePass.php
File metadata and controls
30 lines (26 loc) · 874 Bytes
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
<?php
session_start();
error_reporting(E_ALL);
ini_set("display errors", 1);
require "database.php";
$db = new Database();
$user_id = $_SESSION['id'];
$current = $_POST['current'];
$new = $_POST['newpass'];
$stmt = $db->prepare("SELECT * FROM users WHERE user_id=:user_id;");
$stmt->bindValue(':user_id',$user_id, SQLITE3_INTEGER);
if(($user = $users->fetchArray())) {
$salt = $user['salt'];
$pass = sha1($salt."--".$current);
if($pass === $user['pass']) {
$encrypted_pass = sha1($salt."--".$new);
$stmt = $db->prepare("UPDATE users SET pass=".$encrypted_pass." WHERE user_id=:user_id;");
$stmt->bindValue(':user_id',$user_id, SQLITE3_INTEGER)
$stmt->execute();
;
$stmt = $db->prepare("INSERT INTO notifs VALUES(NULL,:user_id,'Password changed');")
$stmt->bindValue(':user_id',$user_id, SQLITE3_INTEGER);
$stmt->execute();
}
}
?>