Jumat, 01 Juni 2018

Tugas Pemrograman Web

Tutorial Tugas Proweb

Nama : Welly Oktavianus
NIM : 5150411100
Kelas : TI B

Tutorial Membuat input Data Pribadi Diperkuliahan, jadi disini saya membuat program tentang menginput data bagaimana menginput data di program disini saya akan menampilkan gambar dan sourcode yang sudah saya buat, jadi teman-teman bisa lanjutin, maaf bila program saya kurang menarik dan salah, terima kasih

gambar tamplan :




Sourcode :

-index.php :
<!DOCTYPE html>
<html>
<head>
<title>Tugas Pemrograman WEB</title>
        <link rel="stylesheet"href="assets/css/bootstrap.min.css">
        <link rel="stylesheet"href="assets/css/floating-labels.css">
        <script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
        <script src="assets/js/jquery-3.2.1.slim.min.js"></script>
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/bootstrap.min.js"></script>
</head>
<body>
        <div class="container">
<div style="height:50px;"></div>
<div class="well" style="margin:auto; padding:auto; width:80%;">
<span style="font-size:25px; color:blue"><center><strong>Tugas Proweb</strong></center></span>
        <?php include ('modal.php'); ?>
<span class="pull-left"><a href="#modal" data-toggle="modal" class="btn btn-primary">
        <span class="glyphicon glyphicon-plus"></span> tambah</a></span>
<div style="height:40px;"></div>
<table class="table table-striped table-bordered table-hover">
<thead>
<th>No</th>
<th>NIM</th>
<th>NAMA</th>
<th>JURUSAN</th>
                                <th>KELAS</th>
                                <th>AKSI</th>
</thead>
<tbody>
<?php
include('koneksi.php');
$query=mysqli_query($conn,"select * from `project`");
while($row=mysqli_fetch_array($query)){
?>
<tr>
<td><?php echo $row['no']; ?></td>
<td><?php echo $row['nim']; ?></td>
<td><?php echo $row['nama']; ?></td>
                        <td><?php echo $row['jurusan']; ?></td>
                         <td><?php echo $row['kelas']; ?></td>
<td>
     <?php include('modal_ubah.php'); ?>
<a href="#ubah<?php echo $row['no']; ?>" data-toggle="modal" class="btn btn-warning"><span class="glyphicon glyphicon-edit"></span> Edit</a> ||
     <?php include('modal_hapus.php'); ?>
<a href="#hapus<?php echo $row['no']; ?>" data-toggle="modal" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Delete</a>

</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</body>
</html>


-koneksi.php :
<?php
$conn = mysqli_connect("localhost","root","","proweb");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

?>

-hapus :
<?php
include('koneksi.php');
$no=$_GET['no'];
mysqli_query($conn,"delete from mahasiswa where no='$no'");
header('location:index.php');


?>

-modal :
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel"></h4></center>
                </div>
                <div class="modal-body">
<div class="container-fluid">
                                    <form method="POST" action="simpan.php">
<div class="row">
<div class="col-lg-2">
<label class="control-label" style="position:relative; top:7px;">NIM:</label>
</div>
<div class="col-lg-10">
<input type="text" class="form-control" name="NIM">
</div>
</div>
                                       
<div style="height:10px;"></div>
<div class="row">
<div class="col-lg-2">
<label class="control-label" style="position:relative; top:7px;">NAMA:</label>
</div>
<div class="col-lg-10">
<input type="text" class="form-control" name="nama">
</div>
</div>
                                       
<div style="height:10px;"></div>
<div class="row">
<div class="col-lg-2">
<label class="control-label" style="position:relative; top:7px;">JURUSAN:</label>
</div>
<div class="col-lg-10">
<input type="text" class="form-control" name="jurusan">
</div>
</div>
                                       
                                        <div style="height:10px;"></div>
<div class="row">
<div class="col-lg-2">
<label class="control-label" style="position:relative; top:7px;">KELAS:</label>
</div>
<div class="col-lg-10">
<input type="text" class="form-control" name="kelas">
</div>
</div>
                </div>
</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk"></span> Save</a>
</form>
                </div>

            </div>
        </div>

    </div>

-modalhapus :
<div class="modal fade" id="hapus" <?php echo $row['no']; ?>tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <center><h4 class="modal-title" id="myModalLabel">Hapus</h4></center>
                </div>
                <div class="modal-body">
                    <?php
                        $hapus=mysql1_query($conn,"select * form datasaya where no='".$row['no']."'");
                        $drow=mysql1_fetch_array($hapus);
                    ?>
<div class="container-fluid">
                                    <h5><center>NIM: <strong><?php echo $drow['nim']; ?></strong></center></h5>
                </div>
</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
                    <a href="hapus.php?no=<?php echo $row['no']; ?>" class="btn btn-danger"><span class="glyphicon glyphicon-trash"> </span> Delete</a>
</form>
                </div>

            </div>
        </div>

    </div>

-simpan :
<?php
include('koneksi.php');

$nim=$_POST['nim'];
$nama=$_POST['nama'];
$jurusan=$_POST['jurusan'];
        $kelas=$_POST['kelas'];

mysqli_query($conn,"insert into mahasiswa (nim, nama, jurusan, kelas) values ('$nim', '$nama', '$jurusan', '$kelas')");
header('location:index.php');


?>

-ubah :
<?php
include('koneksi.php');

$no=$_GET['no'];
$nim=$_POST['nim'];
$namae=$_POST['nama'];
$jurusan=$_POST['jurusan'];
        $kelas=$_POST['kelas'];

mysqli_query($conn,"update mahasiswa set nim='$nim', nama='$nama', jurusan='$jurusan', kelas='$kelas' where no='$no'");
header('location:index.php');


?>