<?php
    session_start();
    include '../prijava/connect.php';
    setlocale(LC_TIME,"hr_HR");
    date_default_timezone_set("Europe/Zagreb");
    
    if ($dbc) {
        $id = $_GET['id'];
        $query = "SELECT * FROM user WHERE id = $id";
        $result = mysqli_query($dbc,$query) or die('Error querying database.');
        if($result) {
            while($row = mysqli_fetch_array($result)) {
                if($row['admin'] == 1) {
                    $query2 = "UPDATE user SET admin = 0 WHERE id = $id";
                    $result = mysqli_query($dbc,$query2) or die('Error querying database.');
                } else {
                    $query2 = "UPDATE user SET admin = 1 WHERE id = $id";
                    $result = mysqli_query($dbc,$query2) or die('Error querying database.');
                }
            }
        }
    }
?>