View sourcecode

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

errase.php

25 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
```php
<?php

$username 
= $_POST['username'];
$password = $_POST['password'];

$filename = $username . '.json';
if (!
file_exists($filename)) {
    
header('location:index.php?mess=Kontot finns inte');
    exit();
}

$users = json_decode(file_get_contents($filename), true);

foreach (
$users as $user) {
    if (
$user['username'] == $username && $user['password'] == $password){
        if (
unlink($filename)) {
            
header('location:index.php?mess=Kontot har raderats');
            exit();
        } 
    }
}