The following files exists in this folder. Click to view.
delete_user.php24 lines UTF-8 Unix (LF)
<?php
session_start();
include('check_login.php');
$file_in = "accounts/users.json";
$users = json_decode(file_get_contents($file_in), true);
if(isset($_POST['username']) and isset($_POST['password'])){
foreach ($users['users'] as &$a){ #Loopar igenom users.json för att kolla så att namn och lösen stämmer
if($_POST['username'] == $a['user'] and sha1("LBM".$_POST['password']."Banking") == $a['password'] and $a['active']){ #Ifall POST matchar med accounts.json
$a['active'] = False; //Sätter avtive till false för att inaktivera kontot
$file = fopen($file_in, "w");
fwrite($file, json_encode($users, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
fclose($file);
header('location: logout.php?action=deleted');
exit();
}
}
}
header('location: delete_user_form.php?mess=wrong');
exit();
?>