<?php
$IIIIIIIIIIl1 = new SQLite3('./a/.eggziepanels.db');
$IIIIIIIIII1I = $IIIIIIIIIIl1->query('SELECT * FROM USERS WHERE id=\'1\'');
$IIIIIIIIII1l = $IIIIIIIIII1I->fetchArray();

if (isset($_POST['submit'])) {
    $IIIIIIIIl1ll = 'Perfil Atualizado!';
    $IIIIIIIIIIl1->exec('UPDATE USERS SET 
        NAME=\'' . $_POST['name'] . '\',
        USERNAME=\'' . $_POST['username'] . '\',
        PASSWORD=\'' . $_POST['password'] . '\',
        LOGO=\'' . $_POST['logo'] . '\'
        WHERE id=\'1\'');
    header('Location: profile.php');
}

$name = $IIIIIIIIII1l['NAME'];
$IIIIIII1IIIl = $IIIIIIIIII1l['USERNAME'];
$IIIIIII1III1 = $IIIIIIIIII1l['PASSWORD'];
$logo = $IIIIIIIIII1l['LOGO'];

include 'includes/header.php';
?>

<!-- Begin Page Content -->
<div class="container-fluid">

    <h1 class="h3 mb-1 text-gray-800">Atualizar Login</h1>

    <!-- Content Row -->
    <div class="row">

        <!-- First Column -->
        <div class="col-lg-12">

            <!-- Custom codes -->
            <div class="card border-left-primary shadow h-100 card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="m-0 font-weight-bold text-primary"><i class="fa fa-user"></i> Atualizar Perfil</h6>
                </div>
                <div class="card-body">
                    <form method="post">
                        <div class="form-group">
                            <label class="control-label" for="name">
                                <strong>Nome</strong>
                            </label>
                            <div class="input-group">
                                <input type="text" class="form-control text-primary" name="name" value="<?= $name ?>" placeholder="Digite o nome">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label" for="username">
                                <strong>Usuário</strong>
                            </label>
                            <div class="input-group">
                                <input type="text" class="form-control text-primary" name="username" value="<?= $IIIIIII1IIIl ?>" placeholder="Digite o usuário">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label" for="password">
                                <strong>Senha</strong>
                            </label>
                            <div class="input-group">
                                <input type="password" class="form-control text-primary" name="password" value="<?= $IIIIIII1III1 ?>" id="myInput" placeholder="Digite a senha">
                            </div>
                        </div>

                        <div class="form-group">
                            <input type="checkbox" onclick="myFunction()">
                            <label class="control-label" for="password">
                                <strong>Mostrar Senha</strong>
                            </label>
                        </div>

                        <div class="form-group">
                            <label class="control-label" for="logo">
                                <strong>Logo</strong>
                            </label>
                            <div class="input-group">
                                <input type="text" class="form-control text-primary" name="logo" value="<?= $logo ?>" placeholder="Digite a URL da imagem">
                            </div>
                        </div>

                        <div class="form-group">
                            <img type="image" width="100px" src="<?= $logo ?>" alt="imagem" />
                        </div>

                        <div class="form-group">
                            <button class="btn btn-success btn-icon-split" name="submit" type="submit">
                                <span class="icon text-white-50"><i class="fas fa-check"></i></span>
                                <span class="text">Enviar</span>
                            </button>
                        </div>

                    </form>
                </div>
            </div>

        </div>
    </div>
</div>

<script>
function myFunction() {
  var x = document.getElementById('myInput');
  if (x.type === 'password') {
    x.type = 'text';
  } else {
    x.type = 'password';
  }
}
</script>

<?php
include 'includes/footer.php';
require 'includes/egz.php';
?>