Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 1 | <?php |
Andreu | 2457e40 | 2019-09-22 00:52:41 +0200 | [diff] [blame] | 2 | require '../credentials.php'; |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 3 | require 'utils.php'; |
| 4 | |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 5 | $credentials = new Credentials(); |
| 6 | $usersdb = $credentials->usersdb; |
| 7 | $mortsdb = $credentials->mortsdb; |
| 8 | |
Adrià Vilanova MartÃnez | d3394e1 | 2022-11-19 15:45:58 +0100 | [diff] [blame^] | 9 | date_default_timezone_set("Europe/Madrid"); |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 10 | |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 11 | // Check if confirmation is the same |
| 12 | if ($_POST['password'] != $_POST['confirmation']) { |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 13 | die("<script>window.location.href = '../main.php?wrongconfirmation=1'</script>"); |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 14 | } else { |
| 15 | // Execute query to change password |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 16 | $update_password = "UPDATE $usersdb SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid']; |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 17 | if(!$result = query($update_password)) die("<script>window.location.href = '../main.php?errordb=1'</script>"); |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 18 | |
| 19 | // Save 'password' to cookies |
| 20 | setcookie('password', md5($_POST['password']), time() + (86400 * 10), "/"); |
| 21 | |
| 22 | // Go back to main page |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 23 | die("<script>window.location.href = '../main.php?successpassword=1'</script>"); |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 24 | } |
| 25 | ?> |