Sythz

Untitled

Jan 12th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1.  
  2. <?php
  3.     include 'lib/library.php';
  4.  
  5.     if ($_SERVER ['REQUEST_METHOD'] == 'POST') {
  6.         $nis    = $_POST['nis'];
  7.         $nama_lengkap = $_POST['nama'];
  8.         $gender = $_POST['gender'];
  9.         $kelas = $_POST['kelas'];
  10.         $jurusan = $_POST['jurusan'];
  11.         $alamat = $_POST['alamat'];
  12.         $gd = $_POST['GD'];
  13.         $ibu = $_POST['ibu'];
  14.         $foto = $_FILES['foto'];
  15.  
  16.         if(!empty($foto) AND $foto['error'] == 0){
  17.             $path = './Media/image/';
  18.             $upload = move_uploaded_file($foto['tmp_name'], $path . $foto['name']);
  19.  
  20.             if(!$upload){
  21.                 flash('error', "Upload File Gagal");
  22.                 header('location:index.php');
  23.             }
  24.             $file = $foto['name'];
  25.         }
  26.  
  27.         $sql = "INSERT INTO siswa(NIS, nama_lengkap, gender, kelas, jurusan, Alamat, Golongan_Darah, Nama_Ibu_Kandung,file) VALUES
  28.                        ('$nis', '$nama_lengkap', '$gender', '$kelas', '$jurusan', '$alamat', '$gd', '$ibu', '$file')";
  29.  
  30.         $mysqli -> query($sql) or die ($mysqli -> error);
  31.  
  32.         header('location: index.php');
  33.     }
  34.  
  35.     include 'view/v_tambah.php';
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment