blob: 6f13127d28e67948cb2820f010f2341cb2432cfc [file] [log] [blame]
Andreu20cbd1d2019-09-22 00:00:57 +02001<?php
Andreu2457e402019-09-22 00:52:41 +02002 require '../credentials.php';
Andreu20cbd1d2019-09-22 00:00:57 +02003 require 'utils.php';
4
5 // Check if confirmation is the same
6 if ($_POST['password'] != $_POST['confirmation']) {
Andreu543e70c2019-09-22 14:08:49 +02007 header("Location: ../main.php?wrongconfirmation=1");
Andreu20cbd1d2019-09-22 00:00:57 +02008 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?>