Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "sisfo";
- // Create connection
- $conn = new mysqli($servername, $username, $password,$dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if (isset($_POST['cmdSubmit'])){
- $nama = $_POST['txtNama'];
- $gender = $_POST['gender'];
- $prodi = $_POST['txtProdi'];
- $status = $_POST['txtStatus'];
- $angkatan = $_POST['txtAngkatan'];
- $tombol = true;
- }else {
- echo "Halaman ini jangan diliatin terus tong.... ";
- $tombol = false;
- }
- ?>
- <title>Data Mahasiswa</title>
- <style>
- body{
- background-color: #b5d2ff;
- font-family: 'PT Sans', sans-serif;
- }
- form{
- text-align: center;
- justify-content: center;
- align-content: center;
- }
- input[type=text],select{
- //display: block;
- background-color: #edf1f7;
- width: 40%;
- padding: 12px 20px;
- margin: 8px 0;
- box-sizing: border-box;
- border-radius: 50px;
- }
- input[type=submit]{
- background-color: #4CAF50;
- border: none;
- color: #fff;
- padding: 16px 32px;
- margin: 8px 0;
- cursor: pointer;
- }
- th{
- padding: 10px;
- }
- tr{
- border: #e0e0e0 1px solid;
- }
- tr:nth-child(even) {
- background-color: #f2f2f2
- }
- td,th{
- border: #e0e0e0 1px solid;
- padding: 15px 35px;
- }
- .kotak{
- border: 1px solid #fff;
- padding: 10px;
- margin: auto 15% 25px;
- }
- .kelas{
- text-align: center;
- justify-content: center;
- align-content: center;
- }
- </style>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.2/skins/all.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.2/skins/flat/_all.css">
- <link href="https://fonts.googleapis.com/css?family=PT+Sans|Cabin" rel="stylesheet">
- </head>
- <body>
- <?php
- if ($tombol) {
- $nol="0";
- $prodi = $nol.$prodi;
- $sql = "SELECT * FROM biodata";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- $a=substr($row["nim"], 7, 10);
- $no_presensi = $a +1;
- }
- }
- if (substr($row["nim"], 7, 10) >=10) {
- $zero1="0";
- $nim = $angkatan.$prodi.$status.$zero1.$no_presensi;
- }elseif (substr($row["nim"], 7, 10) <10) {
- $zero2="00";
- $nim = $angkatan.$prodi.$status.$zero2.$no_presensi;
- }
- $nim = trim($nim);
- $sql = "INSERT INTO biodata (nim, nama, jkel, id_prodi, idstatus) VALUES ('".$nim."', '".$nama."', '".$gender."', '".$prodi."', '".$status."')";
- /*echo $sql;
- exit();*/
- if (mysqli_query($conn, $sql)) {
- echo "<h1 style=\"text-align: center;\">Data Berhasil disimpan</h1>";
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- ?>
- <h1 style="text-align: center;">Input Biodata versi 4.0</h1>
- <div class="kelas">
- <div>
- <label for="txtNim">NIM</label>
- <h2 class="kotak"><?php echo $nim;?></h2>
- <input type="hidden" name="txtNim" id="txtNim" value="<?php echo $nim?>">
- </div>
- <div>
- <label for="txtNama">Nama</label>
- <h2 class="kotak"><?php echo $nama;?></h2>
- <input type="hidden" name="txtNama" id="txtNama" value="<?php echo $nama?>">
- </div>
- <div>
- <label for="gender">Jenis Kelamin</label>
- <h2 class="kotak"><?php echo $gender;?></h2>
- <input type="hidden" name="txtGender" id="txtGender" value="<?php echo $gender?>">
- </div>
- <div>
- <label for="gender">Prodi</label>
- <h2 class="kotak"><?php echo $prodi;?></h2>
- <input type="hidden" name="txtGender" id="txtGender" value="<?php echo $gender?>">
- </div>
- <div>
- <label for="gender">Status</label>
- <h2 class="kotak"><?php echo $status;?></h2>
- <input type="hidden" name="txtGender" id="txtGender" value="<?php echo $gender?>">
- </div>
- <div>
- <label for="gender">Angkatan</label>
- <h2 class="kotak"><?php echo $angkatan;?></h2>
- <input type="hidden" name="txtGender" id="txtGender" value="<?php echo $gender?>">
- </div>
- <button type="button" onclick="javascript:history.back()">Back</button><br>
- <h1><a href="lihat_mhs.php">Lihat Daftar Mahasiswa</a></h1>
- </div>
- <?php } ?>
- <script
- src="https://code.jquery.com/jquery-3.3.1.min.js"
- integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
- crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.2/icheck.min.js"></script>
- <script>
- $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
- checkboxClass: 'icheckbox_flat-green',
- radioClass : 'iradio_flat-green'
- })
- $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
- checkboxClass: 'icheckbox_minimal-blue',
- radioClass : 'iradio_minimal-blue'
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement