connect(); if(!isset($_POST['submit'])){ if (isset($_GET['id'])){ $car = $_GET['id']; $action='update&id='.$_GET['id'].''; $mhs->select('mahasiswa','*',"nim='$car'"); $res = $mhs->getResult(); }else{ $action='insert'; } } else{ if ($_GET['action']=='update'){ $id = $_GET['id']; $nim = $_POST['nim']; $nama = $_POST['nama']; $telp = $_POST['telp']; $asal = $_POST['asal']; $alamat = $_POST['alamat']; if(!empty($_FILES['file']['name'])){ $photos = $mhs->foto($_FILES,$id,'update',$nim); $foto = $foto['lokasi']; } else{ $foto = $mhs->renamefoto($id,$nim); } $rows=array( 'nim' => $nim, 'nama' => $nama, 'telp' => $telp, 'asal' => $asal, 'alamat'=> $alamat, 'foto' => $foto ); if($mhs->update('mahasiswa',$rows,'nim = '.$_GET['id'].'')){ header('Location: index.php'); }else{ echo 'Tidak bisa input'; } } else{ $nim = $_POST['nim']; $nama = $_POST['nama']; $telp = $_POST['telp']; $asal = $_POST['asal']; $alamat = $_POST['alamat']; if(!empty($_FILES['file']['name'])){ $foto = $mhs->foto($_FILES,$nim,'insert',$nim); $lokasi = $foto['lokasi']; $values=array($nim,$nama,$telp,$asal,$alamat,$lokasi); $rows = null; }else{ $values=array($nim,$nama,$telp,$asal,$alamat); $rows= "nim,nama,telp,asal,alamat"; } if($mhs->insert('mahasiswa',$values,$rows)){ header('Location: index.php'); }else{ echo 'Tidak bisa input'; } } } ?> Document
Data
Nama :
NIM :
Alamat :
Telp :
Sekolah Asal :
Photo :