Hallo! Selamat Datang di Marketplace produk digital, Freelancer terbaik di indonesia (68411 Members, 793 Products, 5353 Topic, 13045 Comments)

Apa yang salah di dalam code ini ya, saya edit tapi database tidak masuk??? Mohon bantuannya

Dibuat
Login Terakhir 2 Bulan lalu,
Telah Dilihat 1038 Kali
Sugandi Anarki Mengatakan : Sultan Account
  1. Assalamualaikum Warahmatullahi Wabarakatuh...
  2.  
  3. <?php
  4. include "../../assets/config/koneksi.php";
  5. include "../../assets/phpqrcode/qrlib.php";
  6.  
  7. // Star Webcam
  8. $img = $_POST['webcam'];
  9. $folderPath = "../../assets/img/user/";
  10. $image_parts = explode(";base64,", $img);
  11. $image_type_aux = explode("image/", $image_parts[0]);
  12. $image_type = $image_type_aux[1];
  13. $image_base64 = base64_decode($image_parts[1]);
  14. $fileNama = uniqid() . '.png';
  15. $file = $folderPath . $fileNama;
  16. file_put_contents($file, $image_base64);
  17. // End Webcam
  18.  
  19. $nama = $_POST['a']; //isi QR code
  20. //$nama1 = $_POST['d']; //isi QR code
  21. $nam = $_POST['a']; //isi QR code
  22.  
  23. $nameqrcode = $nam.'.'.'png'; //nama QR Code yang disimpan ke folder dan database
  24. $tempdir = "../../assets/img/qrcode/"; // Nama Folder file QR Code kita nantinya akan disimpan
  25. $isiqrcode = $nama;
  26. $quality = 'H';
  27. $Ukuran = 10;
  28. $padding = 0;
  29.  
  30. QRCode::png($isiqrcode,$tempdir.$nameqrcode,$quality,$Ukuran,$padding); // simpan qrcode
  31.  
  32. date_default_timezone_set('Asia/Jakarta');
  33. $tgl = date("Y-m-d");
  34. $time = date("G:i:s");
  35. $pass=md5($_POST['password']);
  36. if ($_FILES['gambar']['size'] != 0)
  37. {
  38. $fileName = $_FILES['gambar']['name'];
  39. $move = move_uploaded_file($_FILES['gambar']['tmp_name'], "../../assets/img/user/".$_FILES['gambar']['name']);
  40. if($move)
  41. {
  42. mysqli_query($koneksi, "INSERT INTO user (gambar, nama_sekolah, nis, id_level, username, password, nama, jk, tmp_lhr, tgl_lhr, alamat, id_prov, id_kab, id_kec, id_kel, hp, email, tgl_input, waktu, qrcode) VALUES ('$fileName', '$_POST[o]', '$_POST[a]', '$_POST[b]', '$_POST[c]', '$pass', '$_POST[d]', '$_POST[e]', '$_POST[f]', '$_POST[g]', '$_POST[h]', '$_POST[i]', '$_POST[j]', '$_POST[k]', '$_POST[l]', '$_POST[m]', '$_POST[n]', '$tgl', '$time', '$nameqrcode')");
  43. echo "<script>window.alert('Data Berhasil di Input!');
  44. window.location='../view-data'</script>";
  45. }
  46. }
  47. else
  48. {
  49. mysqli_query($koneksi, "INSERT INTO user (gambar, nama_sekolah, nis, id_level, username, password, nama, jk, tmp_lhr, tgl_lhr, alamat, id_prov, id_kab, id_kec, id_kel, hp, email, tgl_input, waktu, qrcode) VALUES ('$fileNama', '$_POST[o]', '$_POST[a]', '$_POST[b]', '$_POST[c]', '$pass', '$_POST[d]', '$_POST[e]', '$_POST[f]', '$_POST[g]', '$_POST[h]', '$_POST[i]', '$_POST[j]', '$_POST[k]', '$_POST[l]', '$_POST[m]', '$_POST[n]', '$tgl', '$time', '$nameqrcode')");
  50. echo "<script>window.alert('Data Berhasil di Input!');
  51. window.location='../view-data'</script>";
  52. }
  53. ?>
  54. ===================================================================================
  55. <?php include "header.php" ?>
  56. <div class="wrapper">
  57. <!-- Star menu -->
  58. <?php include "menu.php";?>
  59. <!-- End menu -->
  60.  
  61. <!-- Start content -->
  62. <div class='content-wrapper'>
  63. <!-- Content Header (Page header) -->
  64. <section class='content-header'>
  65. <h1>
  66. <?php echo "$i[nama] "; ?>
  67. <small>Control panel</small>
  68. </h1>
  69. <ol class='breadcrumb'>
  70. <li><a href='home'><i class='fa fa-dashboard'></i> Home</a></li>
  71. <li class='active'>Tambah Data</li>
  72. </ol>
  73. </section>
  74.  
  75. <!-- Main content -->
  76. <section class='content'>
  77. <div class='row'>
  78. <div class='col-md-12'>
  79. <div class='box box-success'>
  80. <div class='box-header with-border'>
  81. <h3 class='box-title'><i class='fa fa-edit'></i> FORM TAMBAH USER</h3>
  82. </div>
  83. <form class='form-horizontal' role='form' method=POST action='aksi/user_simpanx2.php' enctype='multipart/form-data'>
  84. <div class='box-body'>
  85. <div class='form-group'>
  86.  
  87. <label class='col-sm-2 control-label'>Nama Sekolah : </label>
  88. <div class='col-sm-4'>
  89. <input type='text' class='form-control' name='o' placeholder='Tuliskan Nama Sekolah'>
  90. </div>
  91. </div>
  92. <div class='form-group'>
  93. <label class='col-sm-2 control-label'>Level User :</label>
  94. <div class='col-sm-4'>
  95. <select name='b' class='form-control'>
  96. <?php
  97. $tampil = mysqli_query($koneksi, "SELECT * FROM level where id_level='2' ORDER BY id_level ");
  98. while($r=mysqli_fetch_array($tampil))
  99. {
  100. echo "<option value='".$r['id_level']."' selected>".$r['level']."</option>";
  101. }
  102. ?>
  103. </select>
  104. </div>
  105. </div>
  106. <div class='form-group'>
  107. <label class='col-sm-2 control-label'>Username :</label>
  108. <div class='col-sm-4'>
  109. <input type='text' class='form-control' name='c' placeholder='Tuliskan Username'>
  110. </div>
  111. <label class='col-sm-2 control-label'>Password : </label>
  112. <div class='col-sm-4'>
  113. <input type='password' class='form-control' name='password' placeholder='Tuliskan Password'>
  114. </div>
  115. </div>
  116. <div class='form-group'>
  117. <label class='col-sm-2 control-label'>Nama :</label>
  118. <div class='col-sm-4'>
  119. <input type='text' class='form-control' name='d' placeholder='Tuliskan Nama Lengkap'>
  120. </div>
  121. <label class='col-sm-2 control-label'>JK :</label>
  122. <div class='col-sm-4'>
  123. <select name='e' class='form-control'>
  124. <option value='' selected>Pilih Jenis Kelamin</option>
  125. <option value='Laki-laki' >Laki-laki</option>
  126. <option value='Perempuan' >Perempuan</option>
  127. </select>
  128. </div>
  129. </div>
  130. <div class='form-group'>
  131. <label class='col-sm-2 control-label'>Tempat lahir:</label>
  132. <div class='col-sm-4'>
  133. <input class='form-control' name='f' placeholder='Tuliskan Tempat Lahir'>
  134. </div>
  135. <label class='col-sm-2 control-label'>Tanggal Lahir : </label>
  136. <div class='col-sm-4'>
  137. <input type='date' class='form-control' name='g' value="<?php echo date('Y-m-d'); ?>">
  138. </div>
  139. </div>
  140. <div class='form-group'>
  141. <label class='col-sm-2 control-label'>Alamat :</label>
  142. <div class='col-sm-4'>
  143. <textarea class='form-control' name='h' placeholder='Tuliskan Alamat Rumah'></textarea>
  144. </div>
  145. <label class='col-sm-2 control-label'>Provinsi :</label>
  146. <div class='col-sm-4'>
  147. <select id="provinsi" name='i' class='form-control'>
  148. <option value="">Pilih Provinsi</option>
  149. <?php
  150. $tampil = mysqli_query($koneksi, "SELECT * FROM provinsi ORDER BY nama_provinsi");
  151. while($row=mysqli_fetch_array($tampil)) {
  152. ?>
  153. <option value="<?php echo $row['id_prov']; ?>"><?php echo $row['nama_provinsi']; ?></option>
  154. <?php
  155. }
  156. ?>
  157. </select>
  158. </div>
  159. </div>
  160. <div class='form-group'>
  161. <label class='col-sm-2 control-label'>Kabupaten :</label>
  162. <div class='col-sm-4'>
  163. <select id="kabupaten" name='j' class='form-control' >
  164. <option value='' selected>Pilih Kabupaten</option>
  165. <?php
  166. $tampil = mysqli_query($koneksi, "SELECT * FROM kabupaten ORDER BY nama_kabupaten");
  167. while($row=mysqli_fetch_array($tampil)) {
  168. ?>
  169. <option id="kabupaten" class="<?php echo $row['id_prov']; ?>" value="<?php echo $row['id_kab']; ?>"><?php echo $row['nama_kabupaten']; ?></option>
  170. <?php
  171. }
  172. ?>
  173. </select>
  174. </div>
  175. <label class='col-sm-2 control-label'>Kecamatan :</label>
  176. <div class='col-sm-4'>
  177. <select id="kecamatan" name='k' class='form-control'>
  178. <option value='' selected>Pilih Kecamatan</option>
  179. <?php
  180. $tampil = mysqli_query($koneksi, "SELECT * FROM kecamatan ORDER BY nama_kecamatan");
  181. while($row=mysqli_fetch_array($tampil)) {
  182. ?>
  183. <option id="kecamatan" class="<?php echo $row['id_kab']; ?>" value="<?php echo $row['id_kec']; ?>"><?php echo $row['nama_kecamatan']; ?></option>
  184. <?php
  185. }
  186. ?>
  187. </select>
  188. </div>
  189. </div>
  190. <div class='form-group'>
  191. <label class='col-sm-2 control-label'>Kelurahan : </label>
  192. <div class='col-sm-4'>
  193. <select id="kelurahan" name='l' class='form-control'>
  194. <option value='' selected>Pilih Kelurahan</option>
  195. <?php
  196. $tampil = mysqli_query($koneksi, "SELECT * FROM kelurahan ORDER BY nama_kelurahan");
  197. while($row=mysqli_fetch_array($tampil)) {
  198. ?>
  199. <option id="kelurahan" class="<?php echo $row['id_kec']; ?>" value="<?php echo $row['id_kel']; ?>"><?php echo $row['nama_kelurahan']; ?></option>
  200. <?php
  201. }
  202. ?>
  203. </select>
  204. </div>
  205. <label class='col-sm-2 control-label'>Telp./Hp. : </label>
  206. <div class='col-sm-4'>
  207. <input type='text' class='form-control' name='m' placeholder='Tuliskan Nomor Telp./Hp.'>
  208. </div>
  209. </div>
  210. <div class='form-group'>
  211. <label class='col-sm-2 control-label'>Email : </label>
  212. <div class='col-sm-4'>
  213. <input type='email' class='form-control' name='n' placeholder='Contoh: hadisaputra.bambang@gmail.com'>
  214. </div>
  215. <label class='col-sm-2 control-label'>Unggah Foto :</label>
  216. <div class='col-sm-4'>
  217. <input type='file' class='form-control' name='gambar'>
  218. </div>
  219. </div>
  220.  
  221. <div class='form-group'>
  222. <label class='col-sm-2 control-label'>Foto Webcam : </label>
  223. <div class='col-sm-4'>
  224. <div class="box box-solid box-primary">
  225. <div class="box-header">
  226. <h3 class="panel-title"><i class="fa fa-camera"></i> Camera Webcam</h3>
  227. </div><!-- /.box-header -->
  228. <div class="box-body">
  229. <center> <div id="my_camera"></div><center><br><button class="class='form-control btn btn-flat bg-orange" type=button onClick="take_snapshot()"><i class="glyphicon glyphicon-camera"></i> Ambil Gambar</button>
  230. <input type="hidden" name="webcam" class="image-tag">
  231. </div><!-- /.box-body -->
  232. </div><!-- /.box -->
  233. </div>
  234. <div class="col-md-2"></div>
  235. <div class="col-md-4">
  236. <div class="box box-solid box-danger">
  237. <div class="box-header">
  238. <h3 class="panel-title"><i class="fa fa-camera"></i> Hasil Camera Webcam</h3>
  239. </div><!-- /.box-header -->
  240. <div class="box-body">
  241. <center><div id="results" class="img-thumbnail"><i class="glyphicon glyphicon-camera"></i></center>
  242. </div><!-- /.box-body -->
  243. </div><!-- /.box -->
  244. </div>
  245. </div>
  246.  
  247. </div>
  248.  
  249. <div class='box-footer'>
  250. <label class='col-sm-2 control-label'></label>
  251. <div class='col-sm-10'>
  252. <button style='width: 150px;' type="submit" class="btn btn-flat btn-primary"><i class="glyphicon glyphicon-floppy-save"></i> S I M P A N</button>
  253. <a style='width: 150px;' href="view-data" type="button" class="btn btn-flat btn-danger"><i class="glyphicon glyphicon-floppy-remove"></i> B A T A L</a>
  254. </div>
  255. </div>
  256. </div>
  257. </form>
  258. </div>
  259. </div>
  260. </section>
  261. <!-- /.content -->
  262. </div>
  263. <!-- End content --><script src="../assets/webcam/java.js"></script>
  264. <script src="../assets/webcam/webcam.min.js"></script>
  265. <script language="JavaScript">
  266. Webcam.set({
  267. // live preview size
  268. width: 300,
  269. height: 230,
  270.  
  271. // device capture size
  272. dest_width: 300,
  273. dest_height: 230,
  274.  
  275. // final cropped size
  276. crop_width: 184,
  277. crop_height: 230,
  278.  
  279. // format and quality
  280. image_format: 'jpeg',
  281. jpeg_quality: 90
  282. });
  283.  
  284. Webcam.attach( '#my_camera' );
  285.  
  286. function take_snapshot() {
  287. Webcam.snap( function(data_uri) {
  288. $(".image-tag").val(data_uri);
  289. document.getElementById('results').innerHTML = '<img src="'+data_uri+'"/>';
  290. } );
  291. }
  292. </script>
  293. <?php include "footer.php";?>
Maaf, Untuk Memberikan Komentar Anda Harus Login !!!

Online