The following files exists in this folder. Click to view.
skapa_konto.php28 lines ASCII Unix (LF)
<?php
session_start();
include('check_login.php');
include('functions.php');
$file_in = "accounts/".$_SESSION['user'] . $_SESSION['userid'].".json";
$userfile = json_decode(file_get_contents($file_in), true);
$name = $_POST['name'];
foreach ($userfile['accounts'] as $a){
if($a['name'] == $name){
$name = $name . 'I';
}
$id = $a['accountid'];
}
$id = $id+1;
$userfile['accounts'][] = ['name'=> $name, 'accountid'=> $id, 'active'=> True, 'transactions'=> []];
$file = fopen($file_in, "w");
fwrite($file, json_encode($userfile, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
fclose($file);
header('location: home.php');
exit();
?>