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 | |
| 5 | // Check if confirmation is the same |
| 6 | if ($_POST['password'] != $_POST['confirmation']) { |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 7 | die("<script>window.location.href = '../index.php?wrongconfirmation=1'</script>"); |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 8 | } else { |
| 9 | // Execute query to change password |
| 10 | $update_password = "UPDATE users SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid']; |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 11 | if(!$result = query($update_password)) die("<script>window.location.href = '../index.php?errordb=1'</script>"); |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 12 | |
| 13 | // Save 'password' to cookies |
| 14 | setcookie('password', md5($_POST['password']), time() + (86400 * 10), "/"); |
| 15 | |
| 16 | // Go back to main page |
Andreu | 0d0f9fd | 2019-09-23 03:56:08 +0200 | [diff] [blame] | 17 | die("<script>window.location.href = '../index.php?successpassword=1'</script>"); |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 18 | } |
| 19 | ?> |