Selasa, 10 Oktober 2017

Data Mahasiswa Teknik Informatika


pada postingan kali ini saya akan membahas cara membuat Data mahasiswa teknik informatika menggunakan script.
dan saya menggunakan PhpMyAdmin "Xampp"
1. Melakukan pengecekan pada control Xampp da memastikan Xampp telah Start.

Gambar 1.1 Start Xampp

 2. Membuka web browser dengan alamat “localhost/dashboard” dan membuka PypMyAdmin
  

Gambar 1.2 Tampilan Localhost/dashboard

3. Membuat Database / Basis Data mhs_informatika

Gambar 1.3  Membuat Database 
  

Gambar 1.4 Tampil Membuat Database

4. Membuat table pada database data_mhs


Gambar 1.5 Membuat Tabel

Gambar 1.6 Tampilan Mengisi Field Tabel Database
Gambar 1.7 Tampilan data_mhs yang Telah Terisi

5. Membuat folder pada Htdocs yang terletak di dalam Xampp

Gambar 1.8 Htdocs dalam folder Xampp
  

Gambar 1.9 folder mhs_informatika

6. Membuka Program Data Mahasiswa Teknik Informatika dengan alamat “localhost/mhs_mahasiswa” dan melakukan tambah data
Gambar 1.10 Tampilan search mhs_informatika
  

Gambar 1.11 Tampilan Halaman Depan mhs_informatika

7. Menambahkan data mahasiswa Teknik Informatika

Gambar 1.12 Submit data Data
  
Gambar 1.13 Tampilan data pada PhpMyAdmin

8.  Melakukan pengeditan data mahasiswa Teknik Informatika

Gambar 1.14 Tampilan hasil tambah dan edit


Gambar 1.15 Form Edit Data


Gambar 1.16 Tampilan Setelah di Edit

 9. Menghapus data mahasiswa Teknik Informatika

Gambar 1.17 Tampilan data yang akan di hapus


Gambar 1.18 Form Hapus Data
  

Gambar 1.19 Tampilan PhpMyAdmin Setelah di Hapus


Gambar 1.20 Tampilan Data Mahasiswa Teknik Informatika yang kosong

*  Baik  sekarang saya akan menuliskan script untuk data mahasiswa teknik informatika


1.      Script Koneksi “db.php”
<?php
ob_start();
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'mhs_informatika');
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
$database = mysql_select_db(DB_DATABASE) or die(mysql_error());
?>

2.      Script Halaman utama”index.php”
<!doctype html>
<html>
<head>
            <title>Halaman Utama</title>
</head>
<style>
.container{
            width:900px;
            margin:0px auto;
}
.menu_atas{
            width:300px;
            height:auto;
            margin:0px auto;
            background-color:red;
            padding:5px;
}
.menu_atas ul{
}
.menu_atas li{
            list-style:none;
}
.menu_atas a{
            text-decoration:none;
}
</style>
<body>
<div class='container'>
            <div class='menu_atas'>
                        <ul>
                                    <li><a href='form_tambah.php'> Tambah Data </a></li>
                                    <li><a href='view.php'>Tampil Data</a></li>
                        </ul>
            </div>
</div>
</body>
</html>

3.      Script Tambah data “form_tambah.php”
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Data Mahasiswa Teknik Informatika</title>
<link type="text/css" media="all" rel="stylesheet" href="style.css">
</head>

<body>
<div class="display">
<form action="insert.php" method="post" name="insertform">
<p>
<label for="npm" id="preinput">My NPM : </label>
<input type="text" name="npm" required placeholder="isi npm mu" id="inputid"/>
</p>
<p>
<label for="name" id="preinput">My Name : </label>
<input type="text" name="name" required placeholder="Nama Lengkap" id="inputid"/>
</p>
<p>
<label for="school" id="preinput">My School : </label>
<input type="school" name="school" required placeholder="from the school" id="inputid" />
</p>
<p>
<label for="address" id="preinput"> My Address: </label>
<input type="text" name="address" required placeholder="address" id="inputid"/>
</p>
<p>
<input type="submit" name="send" value="Submit" id="inputid" />
</p>
</form>
</div>
<?php include('view.php'); ?>
</body>
</html>

4.      Script submit data “insert.php”
<?php
ob_start();
include("db.php");
if(isset($_POST['send'])!="")
{
$npm=mysql_real_escape_string($_POST['npm']);
$name=mysql_real_escape_string($_POST['name']);
$school=mysql_real_escape_string($_POST['school']);
$address=mysql_real_escape_string($_POST['address']);
$update=mysql_query("INSERT INTO data_mhs ( npm, name, school, address, created ) VALUES ( '$npm', '$name', '$school', '$address', now())" );
if($update)
{
            echo"<script>alert('Data berhasil di tambahkan'); window.location='view.php'</script>";
}
else
{
}
}
ob_end_flush();
?>

5.      Script Tampilan data “view.php”
<link rel="stylesheet" href="style.css" type="text/css">
<?php
include('db.php');
$select=mysql_query("SELECT * FROM data_mhs order by id desc");
$i=1;
while($userrow=mysql_fetch_array($select))
{
$id=$userrow['id'];
$npm=$userrow['npm'];
$name=$userrow['name'];
$school=$userrow['school'];
$address=$userrow['address'];
$created=$userrow['created'];
?>
<div class="display">
<p>My NPM : <span><?php echo $npm; ?></span>
<a href="delete.php?id=<?php echo $id; ?>"
onclick="return confirm('Are you sure you wish to delete this Record?');">
<span class="delete" title="Delete"> X </span></a>
</p>
<br/>
<p>My NAME : <span><?php echo $name; ?></span>
<a href="edit.php?id=<?php echo $id; ?>"
<a href="edit.php?id=<?php echo $id; ?>"><span class="edit" title="Edit"> E </span></a>
</p>
<br />
<p>My SCHOOL: <span><?php echo $school; ?></span>
</p>
<br />
<p> My ADDRESS : <span><?php echo $address; ?></span>
</p>
<br />
<p>Tersimpan On : <span><?php echo $created; ?></span>
</p>
<br />
<p>
<a href="form_tambah.php?id=<?php echo $id; ?>"
<a href="form_tambah.php?id=<?php echo $id; ?>"><span class="tambah" title="Tambah"> Back </span></a>
</p>
<br />
<p>
<a href="view.php?id=<?php echo $id; ?>"
<a href="view.php?id=<?php echo $id; ?>"><span class="tampil" title="Tampil"> View </span></a>
</p>
<br />
</div>
<?php } ?>

6.      Script edit “edit.php”
<?php
ob_start();
include('db.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['update']))
{
$npm=$_POST['npm'];
$name=$_POST['name'];
$school=$_POST['school'];
$address=$_POST['address'];
$updated=mysql_query("UPDATE data_mhs SET npm = '$npm', name = '$name', school = '$school', address = '$address' WHERE id='$id'")or die();
if($updated)
{
$msg="Successfully Updated!!";
header('Location:view.php');
}
}
}
ob_end_flush();
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit form</title>
<link type="text/css" media="all" rel="stylesheet" href="style.css">
</head>
<body>
<?php
if(isset($_GET['id']))
{
$id=$_GET['id'];
$getselect=mysql_query("SELECT * FROM data_mhs WHERE id='$id'");
while($profile=mysql_fetch_array($getselect))
{
$npm=$profile['npm'];
$name=$profile['name'];
$school=$profile['school'];
$address=$profile['address'];
?>

<div class="display">
<form action="" method="post" name="insertform">
<p>
<label for="npm" id="preinput"> My NPM : </label>
<input type="text" name="npm" required placeholder="NPM"
value="<?php echo $npm; ?>" id="inputid" />
</p>
<p>
<label for="name" id="preinput"> My Name : </label>
<input type="text" name="name" required placeholder="Nama Lengkap"
value="<?php echo $name; ?>" id="inputid" />
</p>
<p>
<label for="school" id="preinput"> My School : </label>
<input type="school" name="school" required placeholder="From the school"
value="<?php echo $school; ?>" id="inputid" />
</p>
<p>
<label for="address" id="preinput"> My Address : </label>
<input type="text" name="address" required placeholder="Address"
value="<?php echo $address; ?>" id="inputid" />
</p>
<p>
<input type="submit" name="update" value="Update" id="inputid" />
</p></form></div>
<?php } } ?>
</body>
</html>


7.      Script delete “delete.php”
<?php
ob_start();
include('db.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['delete']))
{
$updated=mysql_query("DELETE FROM data_mhs WHERE id=".$id)or die("Gagal menghapus data");
if($updated)
{
$msg="Data Berhasil Dihapus";
header('Location:form_tambah.php');
}}}
ob_end_flush();
?>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Delete form</title>
<link type="text/css" media="all" rel="stylesheet" href="style.css">
</head>
<body>
<?php
if(isset($_GET['id']))
{
$id=$_GET['id'];
$getselect=mysql_query("SELECT * FROM data_mhs WHERE id='$id'");
while($profile=mysql_fetch_array($getselect)){
$npm=$profile['npm'];
$name=$profile['name'];
$school=$profile['school'];
$address=$profile['address'];
?>
<div class="display">
<form action="" method="post" name="insertform">
<p>
<label for="npm" id="preinput"> My NPM : </label>
<input type="text" name="npm" required placeholder="Npm mu"
value="<?php echo $npm; ?>" id="inputid" />
</p>
<p>
<label for="name" id="preinput"> My Name : </label>
<input type="text" name="name" required placeholder="Nama Lengkap"
value="<?php echo $name; ?>" id="inputid" />
</p>
<p>
<label for="school" id="preinput"> My School : </label>
<input type="school" name="school" required placeholder="From The School"
value="<?php echo $school; ?>" id="inputid" />
</p>
<p>
<label for="address" id="preinput"> My Address : </label>
<input type="text" name="address" required placeholder="Address"
value="<?php echo $address; ?>" id="inputid" />
</p>
<p>
<input type="submit" name="delete" value="delete" id="inputid" />
</p>
</form>
</div>
<?php } } ?>
</body>
</html>

8.      Script css “style.css”
@charset "utf-8";
/* CSS Document */
* {
margin:0;
padding:0;
margin:0 auto;
font-family:Tahoma, Geneva, sans-serif;
color:#040;
}
p {
margin-top:10px;
}
span {
color:#030;
}
#preinput {
width:250px;
float:left;
}
.display {
width:30%;
border:1px green solid;
padding:1%;
margin-bottom:10px;
margin-top:10px;
}
.delete {
float:right;
color:#F00;
font-weight:bold;
}
.edit {
float:right;
color:#033;
font-weight:bold;
}
#inputid {
width:280px;
padding:10px;
}
#inputid1 {
width:305px;
padding:10px;
}


cara membuat data mahasiswa teknik informatika telah  selesai,  terimakasih sudah melihat postingan  saya.
Assalamualaikum wr.wb

dosen  pengampu:


Muhammad Ropianto, S.Kom,  M.Kom

0 komentar:

Posting Komentar