/
changePassword.php
55 lines (39 loc) · 1.1 KB
/
changePassword.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
49
50
51
52
53
54
55
<?php
require_once("./src/connections.php");
if (isset($_SESSION['userId']) !== TRUE) {
header("Location: login.php");
}
$user = User::GetUserById($_SESSION['userId']);
?>
<form method='POST'>
<fieldset>
<legend>Zmień hasło</legend>
<p>
<label>Stare hasło:
<input type='password' name='oldpassword'>
</label>
</p>
<p>
<label>Nowe hasło:
<input type='password' name='password1'>
</label>
</p>
<p>
<label>Powtórz hasło:
<input type='password' name='password2'>
</label>
<p>
<input type='submit' value='Zmień hasło'>
</p>
</fieldset>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if($user->changePassword(($_POST['oldpassword']), ($_POST['password1']), ($_POST['password2']))){
echo("Hasło zostało zmienione poprawnie");
}
else{
echo("Nieprawidłowe dane");
}
}
?>