Untitled
heheheheuser_4374499293
javascript
3 years ago
5.5 kB
4
Indexable
Never
<?php //koneksi database $server = "localhost"; $user = "root"; $pass = ""; $database = "db_formmahasiswa"; $koneksi = mysqli_connect($server, $user, $pass, $database) or die(mysqli_error($koneksi)); // jika tombol simpan di klik if(isset($_POST['bsimpan'])) { $simpan = mysqli_query($koneksi, "INSERT INTO tbl_mhs (nim, nama, jurusan, jenjang, nama_sekolah, tahun_lulus, alamat) VALUES ('$_POST[tnama]', '$_POST[tnama]', '$_POST[tjurusan]', '$_POST[tjenjang]', '$_POST[tnama_sekolah]', '$_POST[talamat]') "); if($simpan)//jika simpan sukses { echo <script> alert('simpan data sukses!'); document.location='index.php'; </script>; } else { echo <script> alert('simpan data gagal!'); document.location='index.php'; </script>; } } ?> <!DOCTYPE html> <html> <head> <title>FORM MAHASISWA</title> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> </head> <body> <div class="container"> <h1 class="text-center"> FORM MAHASISWA </h1> <h2 class="text-center">TELKOM UNIVERSITY</h2> <!-- Awal Card Form --> <div class="card mt-3"> <div class="card-header bg-primary text-white "> Form Input Data Pribadi </div> <div class="card-body"> <form method="post" action=""> <div class="form-group"> <label>Nama</label> <input type=" text" name="tnama"class="form-control" placeholder="Input Nama anda disini"> </div> <div class="form-group"> <label>NIM</label> <input type=" text" name="tnim"class="form-control" placeholder="Input Nim anda disini"> </div> <div class="form-group"> <label>Jurusan</label> <select class="form-control" name="tjurusan"> <option></option> <option value="Teknologi Rekayasa Multimedia">Teknologi Rekayasa Multimedia</option> <option value="Sistem Informatika">Teknologi Komputer</option> <option value="Digital Marketing">Digital Marketing</option> </select> </div> <!-- Tengah Card Form --> <div class="card mt-3"> <div class="card-header bg-primary text-white "> Form Input Riwayat Pendidikan </div> <div class="card-body"> <form method="post" action=""> <div class="form-group"> <label>Jenjang</label> <select class="form-control" name="tjenjang"> <option></option> <option value="SMA">SMA</option> <option value="SMK">SMK</option> <option value="SMEA">SMEA</option> </select> </div> <div class="form-group"> <label>Nama Sekolah</label> <input type="text" name="tnama_sekolah"class="form-control" placeholder="input nama sekolah disini"> </div> <div class="form-group"> <label>Tahun Lulus</label> <select class="form-control" name="tjenjang"> <option></option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> </select> </div> </div> <div class="form-group"> <label>Alamatl> <input type="text" name="talamat"form-control" placeholder="Input alamat disini"> </div> <button type="submit" class="btn btn-success" name="bsimpan">Simpan</button> <button type="reset" class="btn btn-danger" name="breset">Kosongkan</button> </div> <!-- Akhir Card Form --> <!-- Awal Card Tabel --> <div class="card mt-3"> <div class="card-header bg-success text-white "> Daftar Data Pribadi & Riwayat Pendidikan </div> <div class="card-body"> <table class="table table-bordered table-striped"> <tr> <th>No.</th> <th>NIM</th> <th>Nama</th> <th>Jurusan</th> <th>Jenjang</th> <th>Nama Sekolah</th> <th>Tahun Lulus</th> <th>Alamat</th> <th>Aksi</th> </tr> <?php $no = 1 ; $tampil = mysqli_query($koneksi, "SELECT * from tbl_mhs order by id_mhs desc "); while($data = mysqli_fetch_array($tampil)) : ?> <tr> <td><?=$no++?></td> <td><?=$data['nim']?></td> <td><?=$data['nama']?></td> <td><?=$data['jurusan']?></td> <td><?=$data['jenjang']?></td> <td><?=$data['nama_sekolah']?></td> <td><?=$data['tahun_lulus']?></td> <td><?=$data['alamat']?></td> <td> <a href="#" class="btn btn - warning"> edit </a> <a href="#" class="btn btn - danger"> hapus </a> </td> </tr> <?php endwhile; //penutup perulangan while?> </table> <div> </div> <!-- Akhir Card Tabel --> </div> <script type="text/javascript" src="js/bootstrap.min.js"></script> </body> </html>