Advertisement
Sythz

Untitled

Jan 12th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2.     include 'lib/library.php';
  3.     $nis = $_GET['nis'];
  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.         $file = $_POST['foto'];
  15.  
  16.         $foto = $_FILES['foto'];
  17.  
  18.         if(!empty($foto) AND $foto['error'] == 0){
  19.             $path = './Media/image/';
  20.             $upload = move_uploaded_file($foto['tmp_name'], $path . $foto['name']);
  21.  
  22.             if(!$upload){
  23.                 flash('error', "Upload File Gagal");
  24.                 header('location:index.php');
  25.             }
  26.             $file = $foto['name'];
  27.         }
  28.  
  29.         $sql = "UPDATE siswa SET NIS = '$nis',
  30.                nama_lengkap = '$nama_lengkap',
  31.                gender = '$gender',
  32.                kelas = '$kelas',
  33.                jurusan = '$jurusan',
  34.                Alamat = '$alamat',
  35.                Golongan_Darah = '$gd',
  36.                file = '$file',
  37.                Nama_Ibu_Kandung = '$ibu' WHERE NIS = '$nis'";
  38.  
  39.         if($mysqli->query($sql)){
  40.             flash('success', "Data berhasil diubah");
  41.         }
  42.  
  43.         $mysqli -> query($sql) or die ($mysqli->error);
  44.  
  45.         header ('location: index.php');
  46.     }
  47.            
  48.    
  49.  
  50.     if (empty($nis)) header('location: index.php');
  51.        
  52.         $sql = "SELECT * FROM siswa WHERE NIS = '$nis'";
  53.         $query = $mysqli -> query($sql);
  54.         $siswa = $query -> fetch_array();
  55.  
  56.         if(empty($siswa)) header('location : index.php');
  57.  
  58.         include 'view/v_tambah.php';
  59.    
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement