Advertisement
Guest User

Untitled

a guest
Oct 9th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <?php
  5. $servername = "localhost";
  6. $username = "root";
  7. $password = "";
  8. $dbname = "sisfo";
  9. // Create connection
  10. $conn = new mysqli($servername, $username, $password,$dbname);
  11.  
  12. // Check connection
  13. if ($conn->connect_error) {
  14. die("Connection failed: " . $conn->connect_error);
  15. }
  16.  
  17. if (isset($_POST['cmdSubmit'])){
  18. $nama = $_POST['txtNama'];
  19. $gender = $_POST['gender'];
  20. $prodi = $_POST['txtProdi'];
  21. $status = $_POST['txtStatus'];
  22. $angkatan = $_POST['txtAngkatan'];
  23. $tombol = true;
  24. }else {
  25. echo "Halaman ini jangan diliatin terus tong.... ";
  26. $tombol = false;
  27. }
  28. ?>
  29. <title>Data Mahasiswa</title>
  30. <style>
  31. body{
  32. background-color: #b5d2ff;
  33. font-family: 'PT Sans', sans-serif;
  34. }
  35. form{
  36. text-align: center;
  37. justify-content: center;
  38. align-content: center;
  39. }
  40. input[type=text],select{
  41. //display: block;
  42. background-color: #edf1f7;
  43. width: 40%;
  44. padding: 12px 20px;
  45. margin: 8px 0;
  46. box-sizing: border-box;
  47. border-radius: 50px;
  48. }
  49. input[type=submit]{
  50. background-color: #4CAF50;
  51. border: none;
  52. color: #fff;
  53. padding: 16px 32px;
  54. margin: 8px 0;
  55. cursor: pointer;
  56. }
  57. th{
  58. padding: 10px;
  59. }
  60. tr{
  61. border: #e0e0e0 1px solid;
  62. }
  63. tr:nth-child(even) {
  64. background-color: #f2f2f2
  65. }
  66. td,th{
  67. border: #e0e0e0 1px solid;
  68. padding: 15px 35px;
  69. }
  70. .kotak{
  71. border: 1px solid #fff;
  72. padding: 10px;
  73. margin: auto 15% 25px;
  74. }
  75. .kelas{
  76. text-align: center;
  77. justify-content: center;
  78. align-content: center;
  79. }
  80. </style>
  81. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.2/skins/all.css">
  82. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.2/skins/flat/_all.css">
  83. <link href="https://fonts.googleapis.com/css?family=PT+Sans|Cabin" rel="stylesheet">
  84. </head>
  85. <body>
  86. <?php
  87. if ($tombol) {
  88. $nol="0";
  89. $prodi = $nol.$prodi;
  90.  
  91.  
  92. $sql = "SELECT * FROM biodata";
  93. $result = $conn->query($sql);
  94.  
  95. if ($result->num_rows > 0) {
  96. while($row = $result->fetch_assoc()) {
  97. $a=substr($row["nim"], 7, 10);
  98. $no_presensi = $a +1;
  99. }
  100. }
  101. if (substr($row["nim"], 7, 10) >=10) {
  102. $zero1="0";
  103. $nim = $angkatan.$prodi.$status.$zero1.$no_presensi;
  104. }elseif (substr($row["nim"], 7, 10) <10) {
  105. $zero2="00";
  106. $nim = $angkatan.$prodi.$status.$zero2.$no_presensi;
  107. }
  108. $nim = trim($nim);
  109. $sql = "INSERT INTO biodata (nim, nama, jkel, id_prodi, idstatus) VALUES ('".$nim."', '".$nama."', '".$gender."', '".$prodi."', '".$status."')";
  110. /*echo $sql;
  111. exit();*/
  112. if (mysqli_query($conn, $sql)) {
  113. echo "<h1 style=\"text-align: center;\">Data Berhasil disimpan</h1>";
  114. } else {
  115. echo "Error: " . $sql . "<br>" . mysqli_error($conn);
  116. }
  117. ?>
  118. <h1 style="text-align: center;">Input Biodata versi 4.0</h1>
  119. <div class="kelas">
  120. <div>
  121. <label for="txtNim">NIM</label>
  122. <h2 class="kotak"><?php echo $nim;?></h2>
  123. <input type="hidden" name="txtNim" id="txtNim" value="<?php echo $nim?>">
  124. </div>
  125. <div>
  126. <label for="txtNama">Nama</label>
  127. <h2 class="kotak"><?php echo $nama;?></h2>
  128. <input type="hidden" name="txtNama" id="txtNama" value="<?php echo $nama?>">
  129. </div>
  130. <div>
  131. <label for="gender">Jenis Kelamin</label>
  132. <h2 class="kotak"><?php echo $gender;?></h2>
  133. <input type="hidden" name="txtGender" id="txtGender" value="<?php echo $gender?>">
  134. </div>
  135. <div>
  136. <label for="gender">Prodi</label>
  137. <h2 class="kotak"><?php echo $prodi;?></h2>
  138. <input type="hidden" name="txtGender" id="txtGender" value="<?php echo $gender?>">
  139. </div>
  140. <div>
  141. <label for="gender">Status</label>
  142. <h2 class="kotak"><?php echo $status;?></h2>
  143. <input type="hidden" name="txtGender" id="txtGender" value="<?php echo $gender?>">
  144. </div>
  145. <div>
  146. <label for="gender">Angkatan</label>
  147. <h2 class="kotak"><?php echo $angkatan;?></h2>
  148. <input type="hidden" name="txtGender" id="txtGender" value="<?php echo $gender?>">
  149. </div>
  150. <button type="button" onclick="javascript:history.back()">Back</button><br>
  151. <h1><a href="lihat_mhs.php">Lihat Daftar Mahasiswa</a></h1>
  152. </div>
  153.  
  154. <?php } ?>
  155.  
  156.  
  157. <script
  158. src="https://code.jquery.com/jquery-3.3.1.min.js"
  159. integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  160. crossorigin="anonymous"></script>
  161. <script src="https://cdnjs.cloudflare.com/ajax/libs/iCheck/1.0.2/icheck.min.js"></script>
  162. <script>
  163. $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
  164. checkboxClass: 'icheckbox_flat-green',
  165. radioClass : 'iradio_flat-green'
  166. })
  167. $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
  168. checkboxClass: 'icheckbox_minimal-blue',
  169. radioClass : 'iradio_minimal-blue'
  170. })
  171. </script>
  172. </body>
  173. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement