View sourcecode

The following files exists in this folder. Click to view.

skapa_konto.php

28 lines ASCII Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?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($filejson_encode($userfileJSON_UNESCAPED_UNICODE JSON_PRETTY_PRINT));
    
fclose($file);

    
header('location: home.php'); 
    exit();
?>