Guest User

Untitled

a guest
Jan 27th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.54 KB | None | 0 0
  1. <?php
  2. include 'lib/library.php';
  3. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  4.         $nis            = htmlspecialchars($_POST['nis']);
  5.         $nama_lengkap   = htmlspecialchars($_POST['nama_lengkap']);
  6.         $jenis_kelamin  = htmlspecialchars($_POST['jenis_kelamin']);  
  7.         $kelas          = htmlspecialchars($_POST['id_kelas']);//INI!
  8.         $jurusan        = htmlspecialchars($_POST['jurusan']);
  9.         $gol_darah      = htmlspecialchars($_POST['gol_darah']);
  10.         $alamat         = htmlspecialchars($_POST['alamat']);
  11.         $ibu_k          = htmlspecialchars($_POST['ibu_k']);
  12.         $foto           = $_FILES['foto'];
  13.  
  14.         if (!empty($foto) AND $foto['error'] == 0) {
  15.                 $path = './images/';
  16.                 $upload = move_uploaded_file($foto['tmp_name'],$path.$foto['name']);
  17.  
  18.                 if (!$upload) {
  19.                         flash('error', "upload file gagal");
  20.                         header('location:index.php');
  21.                 }
  22.                 $file = $foto['name'];
  23.         }
  24.        
  25.  
  26.  
  27.         $sql = "INSERT INTO siswa (nis,nama_lengkap,jenis_kelamin,id_kelas,jurusan,gol_darah,alamat,ibu_k,file) VALUES //INI!
  28.        ('$nis', '$nama_lengkap', '$jenis_kelamin', '$kelas', '$jurusan', '$gol_darah', '$alamat', '$ibu_k', '$file') ";
  29.  
  30.  
  31.         $mysqli->query($sql) or die ($mysqli->error);
  32.         header('location: index.php');
  33.  
  34.        
  35. }
  36. //Ambil data kelas
  37. $sql = "SELECT * FROM t_kelas";
  38. $datakelas = $mysqli->query($sql)  or die($mysqli->error);
  39. include 'views/v_tambah.php';
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment