Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <?php
  2. if($_SERVER['REQUEST_METHOD']=='POST'){
  3. $judul = $_POST['judul'];
  4. $refrensi = $_POST['refrensi'];
  5. $isi = $_POST['isi'];
  6. $video = $_POST['video'];
  7. $nip = $_POST['nip'];
  8. $file = $_POST['file'];
  9.  
  10. require_once('dbConnect.php');
  11.  
  12. $no = mysqli_query($con,"select * from data_materi order by id_materi desc limit 0,1");
  13. $no_excute = mysqli_fetch_array($no);
  14. $kodeawal=substr($no_excute['id_materi'],3,4)+1;
  15. if($kodeawal<10){
  16. $kode='PLO000'.$kodeawal;
  17. }elseif($kodeawal > 9 && $kodeawal <=99){
  18. $kode='PLO00'.$kodeawal;
  19. }else{
  20. $kode='TRO00'.$kodeawal;
  21. }
  22.  
  23. $path = "file/$kode.pdf";
  24. $actualpath = "http://mydeveloper.id/app_quiz/$path";
  25.  
  26. // iki tok seng bedo - $_FILES['pdf'] = diambil dari attribute name form
  27. try{
  28. move_uploaded_file($_FILES['pdf']['tmp_name'],$actualpath);
  29.  
  30. }catch(Exception $e){
  31. print_r($e->getMessage());
  32. }
  33.  
  34.  
  35.  
  36. $sql = "insert into data_materi (id_materi, judul,isi, refrensi,video,file,nip) values('$kode','$judul','$isi','$refrensi','$video','$actualpath','$nip')";
  37.  
  38. if(mysqli_query($con,$sql)){
  39. echo "Successfully save";
  40. file_put_contents($path,base64_decode($file));
  41. }
  42. mysqli_close($con);
  43. }else{
  44. echo "Error";
  45. }
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement