blob: 1585a41920804972a8852128a96f24b291976195 [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']) {
Andreu4b2fbd92019-09-22 22:30:25 +02007 die("<script>window.location.href = '../main.php?wrongconfirmation=1'</script>");
Andreu20cbd1d2019-09-22 00:00:57 +02008 } else {
9 // Execute query to change password
10 $update_password = "UPDATE users SET password=\"".md5($_POST['password'])."\" WHERE id=".$_POST['userid'];
Andreu4b2fbd92019-09-22 22:30:25 +020011 if(!$result = query($update_password)) die("<script>window.location.href = '../main.php?errordb=1'</script>");
Andreu20cbd1d2019-09-22 00:00:57 +020012
13 // Save 'password' to cookies
14 setcookie('password', md5($_POST['password']), time() + (86400 * 10), "/");
15
16 // Go back to main page
Andreu4b2fbd92019-09-22 22:30:25 +020017 die("<script>window.location.href = '../main.php?successpassword=1'</script>");
Andreu20cbd1d2019-09-22 00:00:57 +020018 }
19?>