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']) { |
| 7 | header("Location: ../main.php?wrong_password=1"); |
| 8 | die(); |
| 9 | } else { |
| 10 | // Execute query to change password |
| 11 | $update_password = "UPDATE users SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid']; |
| 12 | if(!$result = query($update_password)) header("Location: ../main.php?errordb=1"); |
| 13 | |
| 14 | // Save 'password' to cookies |
| 15 | setcookie('password', md5($_POST['password']), time() + (86400 * 10), "/"); |
| 16 | |
| 17 | // Go back to main page |
| 18 | header("Location: ../main.php?successpassword=1"); |
| 19 | } |
| 20 | ?> |