Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | require 'utils.php'; |
| 3 | |
| 4 | // Check if confirmation is the same |
| 5 | if ($_POST['password'] != $_POST['confirmation']) { |
| 6 | header("Location: ../main.php?wrong_password=1"); |
| 7 | die(); |
| 8 | } else { |
| 9 | // Execute query to change password |
| 10 | $update_password = "UPDATE users SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid']; |
| 11 | if(!$result = query($update_password)) header("Location: ../main.php?errordb=1"); |
| 12 | |
| 13 | // Save 'password' to cookies |
| 14 | setcookie('password', md5($_POST['password']), time() + (86400 * 10), "/"); |
| 15 | |
| 16 | // Go back to main page |
| 17 | header("Location: ../main.php?successpassword=1"); |
| 18 | } |
| 19 | ?> |