<?php
session_start();
if (!isset($_SESSION["login"])) {
    header("Location: login.php");
    exit;
}

require_once(dirname(__FILE__) . '\header.php');

// ambil id data di URL
$id = $_GET["id"];

// query data mahasiswa berdasarkan id
$mhs = query("SELECT * FROM user WHERE id= $id")[0];

?>
<!DOCTYPE html>
<html>

<head>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">

    <!-- CSS yang saya tambahkan -->
    <link rel="stylesheet" href="css/style.css">

    <title>akun</title>
    <style>
        button {
            margin-top: 20px;
            margin-bottom: 20px;
        }

        input {
            margin-left: 20px;
            width: 350px;
            margin-top: 10px;
        }

        .haha {
            margin-left: -150px;
        }

        .nnn {
            width: 250px;
        }

        .ddd {
            background-color: blue;
            color: white;
        }

        .ddd2 {
            background-color: #c0c0c0;
            color: white;
        }
    </style>
</head>

<body>
    <div class="container ddd">
        <h2>
            Data Akun
        </h2>
    </div>
    <form action="" method="POST" enctype="multipart/form-data">
        <input type="hidden" name="id" value="<?= $mhs["id"]; ?>">
        <input type="hidden" name="gambarLama" value="<?= $mhs["gambar"]; ?>">
        <div class="container">
            <div class="form-group row">
                <label for="gambar" class="col-sm-2 col-form-label">Foto </label>
                <div class="col-sm-10">
                    <img src="img/<?= $mhs['gambar']; ?>" width="200" height="200"><br>
                </div>
            </div>
            <div class="form-group row ddd2">
                <label for="nama" class="col-sm-2 col-form-label">Nama Lengkap</label>
                <div class="col-sm-10">
                    <input type="text" readonly class="form-control-plaintext" name="nama" id="nama" required value="<?php echo $mhs["nama"] ?>">
                </div>
            </div>
            <div class="form-group row">
                <label for="alamat" class="col-sm-2 col-form-label">Alamat Lengkap</label>
                <div class="col-sm-10">
                    <input type="text" readonly class="form-control-plaintext" name="alamat" id="alamat" required value="<?php echo $mhs["alamat"] ?>">
                </div>
            </div>
            <div class="form-group row ddd2">
                <label for="nim" class="col-sm-2 col-form-label">NIM</label>
                <div class="col-sm-10">
                    <input type="text" readonly class="form-control-plaintext" name="nim" id="nim" required value="<?php echo $mhs["nim"] ?>">
                </div>
            </div>
            <div class="form-group row">
                <label for="lahir" class="col-sm-2 col-form-label">Tempat/Tanggal Lahir</label>
                <div class="col-sm-10">
                    <input type="text" readonly class="form-control-plaintext" name="tempat" id="tempat" placeholder="Tempat..." required value="<?php echo $mhs["TTL"] ?>">
                </div>
            </div>
            <div class="form-group row ddd2">
                <legend class="col-form-label col-sm-2 pt-0">Jenis Kelamin</legend>
                <?php
                if ($mhs["jenis"] = "L") {
                    $kaka = "Laki-Laki";
                } else {
                    $kaka = "Perempuan";
                }
                ?>
                <div class="col-sm-10">
                    <input type="text" readonly class="form-control-plaintext" name="telepon" id="telepon" required value="<?php echo $kaka ?>">
                </div>
            </div>
            <div class="form-group row">
                <label for="telepon" class="col-sm-2 col-form-label">No. Telepon</label>
                <div class="col-sm-10">
                    <input type="text" readonly class="form-control-plaintext" name="telepon" id="telepon" required value="<?php echo $mhs["telepon"] ?>">
                </div>
            </div>
            <div class="form-group row ddd2">
                <label for="email" class="col-sm-2 col-form-label">Email</label>
                <div class="col-sm-10">
                    <input type="email" readonly class="form-control-plaintext" name="email" id="email" required value="<?php echo $mhs["email"] ?>">
                </div>
            </div>
            <div class="form-group row">
                <label for="kerja" class="col-sm-2 col-form-label">Pekerjaan</label>
                <div class="col-sm-10">
                    <input type="text" readonly class="form-control-plaintext" name="kerja" id="kerja" required value="<?php echo $mhs["pekerjaan"] ?>">
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm">
                    <center>
                        <a class="nav-item btn btn-primary tombol" href="User_UbahAkun.php?id=<?php echo $akun["id"] ?>">Ubah Data Akun</a>
                    </center>
                </div>
            </div>
        </div>
    </form>

    <div class="container ddd">
        <h2>
            Akun User
        </h2>
    </div>
    <div class="container">
        <form action="" method="POST" enctype="multipart/form-data">
            <div class="form-group row">
                <label for="username" class="col-sm-2 col-form-label">Username</label>
                <div class="col-sm">
                    <input type="text" readonly class="form-control-plaintext" name="username" id="username" required value="<?php echo $mhs["username"] ?>">
                </div>
                <div>
                </div>
            </div>
            <div class="form-group row ddd2">
                <label for="password" class="col-sm-2 col-form-label">Password</label>
                <div class="col-sm">
                    <input type="text" readonly class="form-control-plaintext" name="password" id="password" required value="***********">
                </div>
                <div>
                    <a class="nav-item btn btn-primary tombol" href="User_UbahPassword.php?id=<?php echo $akun["id"] ?>">Ubah Password</a>
                </div>
            </div>
        </form>
    </div>
    <?php
    require_once(dirname(__FILE__) . '\footer.php');
    ?>
</body>

</html>