blob: d8bcc19f10cc0c7e4c776c4ebb9ae90fc9f19cae [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
Andreu20af6c22019-09-24 18:33:50 +02005 $credentials = new Credentials();
6 $usersdb = $credentials->usersdb;
7 $mortsdb = $credentials->mortsdb;
8
Andreu20cbd1d2019-09-22 00:00:57 +02009 // Check if confirmation is the same
10 if ($_POST['password'] != $_POST['confirmation']) {
Andreu0d0f9fd2019-09-23 03:56:08 +020011 die("<script>window.location.href = '../index.php?wrongconfirmation=1'</script>");
Andreu20cbd1d2019-09-22 00:00:57 +020012 } else {
13 // Execute query to change password
Andreu20af6c22019-09-24 18:33:50 +020014 $update_password = "UPDATE $usersdb SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid'];
Andreu0d0f9fd2019-09-23 03:56:08 +020015 if(!$result = query($update_password)) die("<script>window.location.href = '../index.php?errordb=1'</script>");
Andreu20cbd1d2019-09-22 00:00:57 +020016
17 // Save 'password' to cookies
18 setcookie('password', md5($_POST['password']), time() + (86400 * 10), "/");
19
20 // Go back to main page
Andreu0d0f9fd2019-09-23 03:56:08 +020021 die("<script>window.location.href = '../index.php?successpassword=1'</script>");
Andreu20cbd1d2019-09-22 00:00:57 +020022 }
23?>