Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
5.9 kB
1
Indexable
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="js/jquery-3.4.1.min.js"></script>
    <script src="js/bootstrap.bundle.min.js"></script>
    <title>Document</title>
</head>
<style>
    ul {
        height: 40px;
        width: 450px;
        margin: 0 auto;
        background: blue;
    }

    li {
        float: left;
        list-style: none;
    }

    a {
        color: white;
        text-decoration: none;
        font-weight: bold;
        padding: 10px 15px;
    }

    a:hover {
        background: blue;
    }
</style>

<body>
    <ul id="menu">
        <li><a href="index.php">Home</a></li>
        <li><a href="data_pendaftaran.php">Pendaftaran</a></li>
        <li><a href="">Jurusan</a></li>
        <li><a href="mahasiswa.php">Mahasiswa</a></li>
    </ul>
    <div class="card-body">
        <form class="form-item" action="" method="post" role="form">
            <div class="card-header bg-primary text-white">FORM Mahasiswa</div>
            <div class="card-body">
                <div class="form-group">
                    <label for="nama">Nama</label>
                    <input type="text" class="form-control col-md-6" name="nama" placeholder="Nama Mahasiswa">
                </div>
                <div class="form-group">
                    <label for="tempat_lahir">Tempat Lahir</label>
                    <input type="text" class="form-control col-md-6" name="tempat_lahir" placeholder="Tempat Lahir">
                </div>
                <div class="form-group">
                    <label for="tanggal_lahir">Tanggal Lahir</label>
                    <input type="date" class="form-control col-md-6" name="tgl_lahir">
                </div>
                <div class="form-group">
                    <label for="jenis_kelamin">Jenis Kelamin</label>
                    <select class="form-control col-md-6" name="jenis_kelamin">
                        <option value="Laki-laki">Laki-laki</option>
                        <option value="Perempuan">Perempuan</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="alamat">Alamat</label>
                    <input type="text" class="form-control col-md-6" name="alamat" placeholder="Alamat">
                </div>
                <div class="form-group">
                    <label for="jurusan">Jurusan</label>
                    <input type="text" class="form-control col-md-6" name="jurusan" placeholder="Jurusan">
                </div>
                <div class="form-group">
                    <label for="email">Email</label>
                    <input type="text" class="form-control col-md-6" name="email" placeholder="Email">
                </div>
                <button type="submit" name="submit" class="btn btn-primary">Tambah</button>
                <button type="reset" class="btn btn-primary">Batal</button>
            </div>
        </form>
    </div>

    <div class="card">
        <?php
        include "koneksi.php";
        if (isset($_POST['submit'])) {
            // $npm = $_POST['npm'];
            $nama = $_POST['nama'];
            $tempat_lahir = $_POST['tempat_lahir'];
            $tgl_lahir = $_POST['tgl_lahir'];
            $jenis_kelamin = $_POST['jenis_kelamin'];
            $alamat = $_POST['alamat'];
            $jurusan = $_POST['jurusan'];
            $email = $_POST['email'];
            mysqli_query($koneksi, "INSERT INTO mahasiswa(nama, tempat_lahir, tgl_lahir, jenis_kelamin, alamat, jurusan, email)
            VALUES ('$nama', '$tempat_lahir', '$tgl_lahir', '$jenis_kelamin', '$alamat', '$jurusan', '$email')")
                or die(mysqli_error($koneksi));
            echo "<div align='center'><h5>Silahkan Tunggu, Data Sedang Disimpan...</h5></div>";
            echo "<meta http-equiv='refresh' content='1, url=http://localhost/uniska/mahasiswa.php'>";
        }
        ?>
    </div>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>NPM</th>
                <th>Nama</th>
                <th>Tempat Lahir</th>
                <th>Tanggal Lahir</th>
                <th>Jenis Kelamin</th>
                <th>Alamat</th>
                <th>Jurusan</th>
                <th>Email</th>
                <th>Aksi</th>
            </tr>
        </thead>
        <tbody>
            <?php
            include "koneksi.php";
            $npm = 1;
            $tampil = mysqli_query($koneksi, "SELECT * FROM mahasiswa");
            while ($row = mysqli_fetch_array($tampil)) {
            ?>
                <tr>
                    <td><?php echo $npm; ?></td>
                    <td><?php echo $row['nama']; ?></td>
                    <td><?php echo $row['tempat_lahir']; ?></td>
                    <td><?php echo $row['tgl_lahir']; ?></td>
                    <td><?php echo $row['jenis_kelamin']; ?></td>
                    <td><?php echo $row['alamat']; ?></td>
                    <td><?php echo $row['jurusan']; ?></td>
                    <td><?php echo $row['email']; ?></td>
                    <td>
                        <a href="edit_mahasiswa.php?npmmahasiswa=<?php echo $row['npm']; ?>" class="btn btn-primary">Edit</a>
                        <a href="delete_mahasiswa.php?npm=<?php echo $row['npm']; ?>" class="btn btn-danger">Hapus</a>
                        <a href="cetak_mahasiswa.php" class="btn btn-success">Cetak</a>
                    </td>
                </tr>
            <?php
                $npm++;
            }
            ?>
        </tbody>
    </table>

</body>