<?php
	require_once('Layout/header.php');
	session_start();
    if(!isset($_SESSION['login'])) {
        include("login.php");
    }
    else {
?>

            <?php
            //koneksi database
            $conn = mysqli_connect("localhost","root","","pa2");
            if($conn->connect_error){
                die("Fatal Error: Can't connect to database: ". $conn->connect_error);
            }
            if(isset($_POST["submit"])){
                
                $namafile = $_POST["namafile"];
                $dosenpengampu = $_POST["dosenpengampu"];
                $jenisfile = $_POST["jenisfile"];
                $prodi = $_POST["prodi"];
                $upload = $_POST["upload"];
                $deskripsi = $_POST["deskripsi"];
                $matakuliah = $_POST["matakuliah"];

                $query = "INSERT INTO dokumen(id_file,mata_kuliah,nama_file,dosen_pengampu,prodi,upload,status,jenis,deskripsi) VALUES('','$namafile','$matakuliah','$dosenpengampu','$prodi','$upload','Dalam Proses','$jenisfile','$deskripsi')";
                mysqli_query($conn,$query);
                print "Masuk";
            }
            ?>
<!-- Melakukan koneksi ke dalam folder layout untuk mendapatkan header -->

<center><h3><b> <img src="img/rps.png" style="width:25px; height:25px;">Upload File</b></h3></center>

<div class="col-md-1">

    <br>
    <a href="daftarFile.php"><button type='button' class='btn btn-primary center-block' style="margin-bottom:20px; border: 1px solid #000000; border-radius: 4px; font-size:12px; background-color:#548FF6;"><img src="img/rps.png" style="width:18px; height:18px;">&nbsp; Daftar File </button></a>
</div>
  
<div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="col-md-10">

    <form action=" " method="post">
        <table width="100%" border="0">
		    <tr> 
                <td><h4><b>Nama File   </b></h4></td>
                <td><input type="text" name="namafile" id="namafile" placeholder="Pemograman Teknologi .NET" size="45" required></td>
            </tr>
            <tr> 
                <td><h4><b>Mata Kuliah   </b></h4></td>
                <td><input type="text" name="matakuliah" id="matakuliah" placeholder="Matakuliah" size="45" required></td>
            </tr>    
            <tr> 
                <td><h4><b>Dosen Pengampu   </b></h4></td>
                <td><input type="text" name="dosenpengampu" id="dosenpengampu" placeholder="Lit Malem Ginting M.T" size="45" required></td>
            </tr>
            <tr>
                <td><h4><b>Jenis File </b></h4></td>
                <td><select class="form-control" name="jenisfile" id="jenisfile" aria-required="true" style="width:200px;">
                            <option value="#">-- Jenis File --</option>
                            <option value="fileRPS">File RPS</option>
                            <option value="fileSoal">File Soal</option>
                            <option value="filePost">File Post Evaluation</option>
                    </select> 
                </td>
            </tr>

            <tr> 
                <td><h4><b>Program Studi  </b></h4></td>
                <td><select class="form-control" name="prodi" id="prodi" aria-required="true" style="width:200px;"> 
                            <option value="#">-- Program Studi --</option>
                            <option value="D3TI">DIII Teknologi Informasi</option>
                            <option value="D3TK">DIII Teknik Komputer</option>
                            <option value="D4TRPL">DIV Teknologi Rekayasa Perangkat Lunak</option>
                            <option value="S1IF">S1 Informatika</option>
                            <option value="S1SI">S1 Sistem Informasi</option>
                            <option value="S1TE">S1 Teknik Elektro</option>               
                </td>
            </tr>

            <tr> 
                <td><h4><b>Upload File   </b></h4></td>
                <td>
                    <input type="file" name="upload" id="upload">
                </td>
            </tr>

            <tr>
                <td><h4><b>Deskripsi </b></h4></td>
                <td>
                        <textarea rows="5" cols="60" name="deskripsi" id="deskripsi"></textarea><br/> 
                </td>
            </tr>
            <br>
            <br>

            <tr>
                <td>
                        <button type="submit" id="submit" name="submit"  class='btn btn-success center-block' style="margin-bottom:20px;">Upload</button> 
                </td>
            </tr>
        </table>
    </form>
    

<br>
</div>
</div>
</div>
</div>


<!-- Melakukan koneksi ke dalam folder layout untuk mendapatkan footer -->
<?php
    require_once('layout/footer.php');
    }
?>

