-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchange.php
49 lines (48 loc) · 1.56 KB
/
change.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
38
39
40
41
42
43
44
45
46
47
48
<?php
session_start();
include "classes/DBase.php";
include "classes/stmt.php";
if(isset($_SESSION['email'])):
$error=false;
if(isset($_POST['password'])):
$email=$_SESSION['email'];
$conn = new DBase("brokfree");
$pdo=$conn->pdo;
$s1=new Stmt($pdo);
$sql='SELECT password_hash from users where email=:email';
$arr=['email'=>$email];
$s1=$s1->run($sql,$arr);
foreach($s1 as $row):
$p_hash=$row['password_hash'];
endforeach;
$password=$_POST['password'];
if(password_verify($password,$p_hash)):
$pnew=$_POST['newpassword'];
$pnew=password_hash($pnew,PASSWORD_DEFAULT);
$sql="UPDATE users SET password_hash=:pass WHERE email=:email";
$arr=[
'email'=> $email,
'pass' => $pnew,
];
$s1= new Stmt($pdo);
$s1->run($sql,$arr);
ob_start();
include "templates/change-confirm.html";
$out=ob_get_clean();
echo $out;
exit();
else:
$error=true;
$msg="enter correct password";
endif;
endif;
ob_start();
include "templates/change.html.php";
$out=ob_get_clean();
echo $out;
else:
ob_start();
include "templates/error.html";
$out=ob_get_clean();
echo $out;
endif;