MY-PROJECT4 SISTEM BASIS DATA
*Data Mahasiswa
Teknik Informatika (Insert,Update,Delete,Query)*
*intro('DB_SERVER', 'localhost')('DB_DATABASE', 'dbempat')(TABLE’,’SAMPLE)
BD koneksi db.php <?phpob_start();define('DB_SERVER', 'localhost');define('DB_USERNAME', 'root');define('DB_PASSWORD', 'root');define('DB_DATABASE', 'dbempat');$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) ordie(mysql_error());$database = mysql_select_db(DB_DATABASE) or die(mysql_error());?>
Coding For à Index.Php <html<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title> .:: MAIN MENU ::. </title></head><body><br/><br/><br/><br/><br/><table width="900" border="2" align="center" cellpadding="6" cellspacing="2" bgcolor="#ffffff"><tr><td height="40" align="center" size="50" bgcolor="#ed9fac"><strong><font color="#FFFFFF"> * INPUT DATA MAHASISWA TEKNIK INFORMATIKA * </font></strong></td></tr><tr><td bgcolor="#f8ecd0"><table width="900" height="200" border="2" align="center" cellpadding="6" cellspacing="2"><p align="center"><a href="input.php">Input Data Mahasiswa</a></p><br/><p align="center"><a href="view.php">Laporan Data Mahasiswa </a></p></tr><p> </p><table width="900" height="40" border="2" align="center" cellpadding="6" cellspacing="2" bgcolor="#ffffff"><tr><td bgcolor="#73b2c4"><table width="700" border="0" align="center" cellpadding="4" cellspacing="2"><p align="center"> * By: <a href="http://tiwisilvia8.blogspot.co.id/">Tiwi Silvia </a></p></tr></html>
Hasil:
HASIL:
Input Data Mahasiswa à input.php <!DOCTYPE><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>.::INPUT DATA MAHASISWA::.</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></p><br /><tr><td height="40" align="center" bgcolor="#669900"><strong><font color="#FFFFFF">INPUT DATA MAHASISWA TEKNIK INFORMATIKA</font></strong></td></tr></p><br /><label for="name" id="preinput">NAME: </label><input type="text" name="username" required placeholder="Your Full Name" id="inputid"/></p><p><label for="email" id="preinput">EMAIL : </label><input type="email" name="usermail" required placeholder="Your Email" id="inputid" /></p><p><label for="mobile" id="preinput"> PHONE NUMBER: </label><input type="text" name="usermobile" required placeholder="Your phone number" id="inputid"/></p><p><br/><input type="submit" name="send" value="Submit" id="inputid" /></p><br/><p align="center"><a href="index.php">Back to main menu </a></p></p></form></div></body></html>
Action= insert.php <?phpob_start();include("db.php");if(isset($_POST['send'])!=""){$username=mysql_real_escape_string($_POST['username']);$usermail=mysql_real_escape_string($_POST['usermail']);$usermobile=mysql_real_escape_string($_POST['usermobile']);$update=mysql_query("INSERT INTO sample(username,emailid,mobileno,created)VALUES('$username','$usermail','$usermobile',now())");if($update){$msg="Successfully Updated!!";echo "<script type='text/javascript'>alert('$msg');</script>";header('Location:view.php');}else{$errormsg="Something went wrong, Try again";echo "<script type='text/javascript'>alert('$errormsg');</script>";header('Location:view.php');}}ob_end_flush();?>
Edit.php <?phpob_start();include('db.php');if(isset($_GET['id'])){$id=$_GET['id'];if(isset($_POST['update'])){$eusername=$_POST['eusername'];$eusermail=$_POST['eusermail'];$emobile=$_POST['eusermobile'];$updated=mysql_query("UPDATE sample SETusername='$eusername', emailid='$eusermail', mobileno='$emobile' WHEREid='$id'")or die();if($updated){$msg="Successfully Updated!!";header('Location:index.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><?phpif(isset($_GET['id'])){$id=$_GET['id'];$getselect=mysql_query("SELECT * FROM sample WHERE id='$id'");while($profile=mysql_fetch_array($getselect)){$username=$profile['username'];$usermail=$profile['emailid'];$usermobile=$profile['mobileno'];?><div class="display"><form action="" method="post" name="insertform"><p><label for="name" id="preinput"> Name : </label><input type="text" name="eusername" required placeholder="Your Full Number"value="<?php echo $username; ?>" id="inputid" /></p><p><label for="email" id="preinput"> Email : </label><input type="email" name="eusermail" required placeholder="Your Email"value="<?php echo $usermail; ?>" id="inputid" /></p><p><label for="mobile" id="preinput"> Phone Number : </label><input type="text" name="eusermobile" required placeholder="Your Phone Number"value="<?php echo $usermobile; ?>" id="inputid" /></p><p><input type="submit" name="update" value="Update" id="inputid" /></p></form></div><?php } } ?></body></html>
HASIL:
View.php <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>.::LAPORAN DATA MAHASISWA::.</title><link type="text/css" media="all" rel="stylesheet" href="style.css"></head><body><?phpinclude('db.php');$select=mysql_query("SELECT * FROM sample order by id desc");$i=1;while($userrow=mysql_fetch_array($select)){$id=$userrow['id'];$username=$userrow['username'];$usermail=$userrow['emailid'];$usermobile=$userrow['mobileno'];$created=$userrow['created']?><div class="display"></p><tr><td height="30" align="center" size="50" bgcolor="#ed9fac"><strong><font color="#FFFFFF"> * LAPORAN DATA MAHASISWA TEKNIK INFORMATIKA * </font></strong></td></tr><br/><p>ID: <span><?php echo $id; ?></span></p><br/><p>NAME : <span><?php echo $username; ?></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"> Delete </span></a></p><br /><p>EMAIL: <span><?php echo $usermail; ?></span><a href="edit.php?id=<?php echo $id; ?>"><span class="edit" title="Edit"> Edit </span></a></p><br /><p>PHONE NUMBER : <span><?php echo $usermobile; ?></span></p><br /><p>Tersimpan On : <span><?php echo $created; ?></span></p><br /></div><?php } ?><p align="center"><a href="index.php">Back to main menu </a></p>
Delete.php <?phpob_start();include('db.php');if(isset($_GET['id'])) <?phpob_start();include('db.php');if(isset($_GET['id'])){$id=$_GET['id'];if(isset($_POST['update'])){$eusername=$_POST['eusername'];$eusermail=$_POST['eusermail'];$emobile=$_POST['eusermobile'];$updated=mysql_query("UPDATE sample SETusername='$eusername', emailid='$eusermail', mobileno='$emobile' WHEREid='$id'")or die();if($updated){$msg="Successfully Updated!!";header('Location:index.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><?phpif(isset($_GET['id'])){$id=$_GET['id'];$getselect=mysql_query("SELECT * FROM sample WHERE id='$id'");while($profile=mysql_fetch_array($getselect)){$username=$profile['username'];$usermail=$profile['emailid'];$usermobile=$profile['mobileno'];?><div class="display"><form action="" method="post" name="insertform"><p><label for="name" id="preinput"> Name : </label><input type="text" name="eusername" required placeholder="Your Full Name"value="<?php echo $username; ?>" id="inputid" /></p><p><label for="email" id="preinput"> Email : </label><input type="email" name="eusermail" required placeholder="Your Email"value="<?php echo $usermail; ?>" id="inputid" /></p><p><label for="mobile" id="preinput"> Phone Number : </label><input type="text" name="eusermobile" required placeholder="Your Phone Number"value="<?php echo $usermobile; ?>" id="inputid" /></p><p><input type="submit" name="update" value="Update" id="inputid" /></p></form></div><?php } } ?></body></html>{$id=$_GET['id'];if(isset($_POST['update'])){$eusername=$_POST['eusername'];$eusermail=$_POST['eusermail'];$emobile=$_POST['eusermobile'];$updated=mysql_query("UPDATE sample SETusername='$eusername', emailid='$eusermail', mobileno='$emobile' WHEREid='$id'")or die();if($updated){$msg="Successfully Updated!!";header('Location:index.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><?phpif(isset($_GET['id'])){$id=$_GET['id'];$getselect=mysql_query("SELECT * FROM sample WHERE id='$id'");while($profile=mysql_fetch_array($getselect)){$username=$profile['username'];$usermail=$profile['emailid'];$usermobile=$profile['mobileno'];?><div class="display"><form action="" method="post" name="insertform"><p><label for="name" id="preinput"> Name : </label><input type="text" name="eusername" required placeholder="Your Full Name"value="<?php echo $username; ?>" id="inputid" /></p><p><label for="email" id="preinput"> Email : </label><input type="email" name="eusermail" required placeholder="Your Email"value="<?php echo $usermail; ?>" id="inputid" /></p><p><label for="mobile" id="preinput"> Phone Number : </label><input type="text" name="eusermobile" required placeholder="Your Phone Number"value="<?php echo $usermobile; ?>" id="inputid" /></p><p><input type="submit" name="update" value="Update" id="inputid" /></p></form></div><?php } } ?></body></html>
Style.CSS @charset "utf-8";/* CSS Document */* {margin:0;padding:0;margin:0 auto;font-family:Tahoma, Geneva, sans-serif;color:#036;}p {margin-top:10px;}span {color:#033;}#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:#039;font-weight:bold;}#inputid {width:280px;padding:10px;}#inputid1 {width:305px;padding:10px;}
.:::DONE !!!
Mata-Kuliah : Sistem Basis Data Dosen-Pengampu : M.Ropianto, M.Kom Asisten-Dosen : JOHN DHAINI