<?php 
session_start();
$ifofuser = $_SESSION["id"];
$db = new SQLite3("./api/db/studiolivecode_users.db");
if (isset($_POST["submit"])) {
    $db->exec("INSERT INTO users(name, username, password, logo, nivel) VALUES('".$_POST['name']."', '".$_POST['username']."', '".$_POST['password']."', '".$_POST['logo']."', '".$_POST['nivel']."')");
    $db->close();
    header("Location: usuarios.php?r=add_sucesso");
}  

?>
<?php include './includes/header.php';?>
<div class="card radius-10">
                  <div class="card-body">
                    <h4 class="card-title">Adicionar Usuário</h4>
                    <form class="forms-sample" method="post" enctype="multipart/form-data">
                      <div class="form-group mb-4">
                        <label for="title"><strong>Nome</strong></label>
                        <input type="text" class="form-control" name="name" id="name" required>
                      </div>
                      <div class="form-group mb-4">
                        <label for="url"><strong>Usuário</strong></label>
                        <input type="text" class="form-control" name="username" id="username" required>
                      </div>
                      <div class="form-group mb-4">
                        <label for="url"><strong>Senha</strong></label>
                        <input type="text" class="form-control" name="password" id="password" required>
                      </div>
                      <div class="form-group mb-4">
                        <label for="url"><strong>Logo</strong></label>
                        <input type="text" class="form-control" name="logo" id="logo" value="img/logo.png">
                      </div>
                      <div class="form-group mb-4">
                        <label for="url"><strong>Nível</strong></label>
                        <select name="nivel" class="form-control" required>
                          <option>Selecione</option>
                          <option value="1">Admin</option>
                          <option value="0">Usuário</option>
                        </select>
                      </div>
                      <button type="submit" name="submit" class="btn btn-primary mr-2"><i class='bx bx-check mr-1'></i>Enviar</button>
                    </form>
                  </div>
                </div>
</div>
				
<?php include './includes/footer.php';?>