You are on page 1of 26

KONEKSI.

PHP

<?php

$server = "localhost";

$username = "root";

$password = "";

$database = "akademik_banisaleh";

mysql_connect($server,$username,$password) or die ("Koneksi Gagal");//mysql_connect berfungsi


untuk setingan koneksi database

mysql_select_db($database) or die ("Database tidak bisa dibuka");//mysql_select_db berfungsi


untuk memilih database yang digunakan

?>

MASTERMAHASISWA.PHP

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Belajar website 2</title>

</head>

<!--ini block fungsi body modify 9/10/2016 by Dyan Novyana-->

<body background="images/dit.jpg">

<table border="0" align="center">

<!--area header-->

<tr>

<td width="1000" height="100" background="images/Domo.jpg"colspan="2" valign="bottom"


style="font-style:italic">
<marquee><h1 style="color:#FFFFFF">**Belajar Website2**</h1></marquee>

<marquee><h1 style="color:#FFFFFF">NovyanaDyan</h1></marquee>

</td>

</tr>

<!--area content dan menu-->

tr>

<td width="300" height="400" bgcolor="#99CCCC" valign="top" style="font-style:italic"><h1


style="color:#FFFFFF">Menu</h1>

<img src="images/cunnn.gif" width="30" height="30">

<a href="mastermahasiswa.php">Home</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="formmahasiswa.php">Profile</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="#">About</a><br><br>

</td>

<td width="600" height="400" bgcolor="#6666CC" valign="top" style="font-style:italic">

<!--area form inputan-->

<table align="center" border="1">

<h3 class="bgputih" align="center"><a href="simpan2.php">Input Mahasiswa</a></h3>

<img src="images/cunnn.gif" width="25" height="25" /><a href=""><b>Print</b></a>

<tr bgcolor="#CC99CC">

<th>No</th>

<th>Nama</th><th>TTL</th><th>Jenis
Kelamin</th><th>Alamat</th><th>Jurusan</th><th>Peminatan 1</th><th>Pemintan
2</th><th>Peminatan 3</th><th>Foto</th><th>Aksi</th>
</tr>

<?php

include "Koneksi.php";

$tampil = mysql_query("SELECT * FROM mahasiswa");

$nomer = 1;

while($r = mysql_fetch_array($tampil))

{ echo "<tr>

<td>$nomer</td>

<td>$r[nama]</td>

<td>$r[ttl]</td>

<td>$r[jk]</td>

<td>$r[alamat]</td>

<td>$r[jurusan]</td>

<td>$r[minat1]</td>

<td>$r[minat2]</td>

<td>$r[minat3]</td>

<td>"; ?>

<img src="images/<?php echo"$r[photo]"; ?>" width="100" height="130" />

</td>

<td align=left><a href=edit.php?id=<?php echo $r[id];?>><b>Edit</b></a>

<a href=hapus.php?id=<?php echo $r[id]?>><b>Hapus</b></a>

</tr>

<?php

$nomer++ ;}
?>

</table>

<!--area footer-->

<tr>

<td width="900" height="50" bgcolor="#FF3366" colspan="2" valign="bottom" style="font-


style:italic">

<h1 style="color:#FFFFFF">Footer</h1>

</td>

</tr>

</body>

</html>

FORMMAHASISWA.PHP

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Belajar website 2</title>

</head>

<!--ini block fungsi body modify 9/10/2016 by Dyan Novyana-->

<body background="images/dit.jpg">

<table border="0" align="center">

<!--area header-->
<tr>

<td width="1000" height="100" background="images/Domo.jpg" colspan="2" valign="bottom"


style="font-style:italic">

<marquee><h1 style="color:#FFFFFF">**Belajar Website2**</h1></marquee>

<marquee><h1 style="color:#FFFFFF">NovyanaDyan</h1></marquee>

</td>

</tr>

<!--area content dan menu-->

tr>

<td width="300" height="400" bgcolor="#99CCCC" valign="top" style="font-style:italic"><h1


style="color:#FFFFFF">Menu</h1>

<img src="images/cunnn.gif" width="30" height="30">

<a href="mastermahasiswa.php">Home</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="formmahasiswa.php">Profile</a><br><br>

<img src="images/cunnn.gif"width="30" height="30">

<a href="#">About</a><br><br>

</td>

<td width="600" height="400" bgcolor="#6666CC" valign="top" style="font-style:italic">

<h1 style="color:#FFFFFF">Form Register</h1>

<!--area form inputan-->

<table>

<form action="simpan.php" name="daftar" method="post" enctype="multipart/form-data">

<tr>
<td width="100">Nama</td>

<td><input type="text" name="nama" maxlength="20" />

</tr>

<tr>

<td width="100">TTL</td>

<td><input type="text" name="ttl" />

</tr>

<tr>

<td width="100" valign="top">Jenis Kelamin</td>

<td><input type="radio" name="jk" value="P" />PRIA<br>

<input type="radio" name="jk" value="W" />WANITA<br>

</td>

</tr>

<tr>

<td width="100" valign="top">Alamat</td>

<td><textarea name="alamat" cols="30" rows="3"> </textarea>

</tr>

<tr>

<td width="100">Jurusan</td>
<td><select name="jurusan">

<option value="TI">Teknik Informatika</option>

<option value="SI">Sistem Informasi</option>

<option value="KA">Komputer Akuntansi</option>

</select>

</tr>

<tr>

<td width="100" valign="top">Peminatan</td>

<td><input type="checkbox" name="Networking" value="Networking" />Network<br>

<input type="checkbox" name="Programing" value="Programing" />Programing <br>

<input type="checkbox" name="DesignGrafis" value="DesignGrafis" />Design Grafis<br>

</td>

</tr>

<tr>

<td width="100">Photo</td>

<td><input name="photo" type="file"/>

</td>

</tr>

<tr>

<td width="100"></td>

<td><input type="submit" name="Save" value="save"/>

</td>
</tr>

</form>

</table>

<!--area footer-->

<tr>

<td width="900" height="50" bgcolor="#FF3366" colspan="2" valign="bottom" style="font-


style:italic">

<h1 style="color:#FFFFFF">Footer</h1>

</td>

</tr>

</body>

</html>

SIMPAN.PHP

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Belajar website 2</title>

</head>

<!--ini block fungsi body modify 9/10/2016 by Dyan Novyana-->

<body background="images/dit.jpg">

<table border="0" align="center">


<!--area header-->

<tr>

<td width="1000" height="100" background="images/Domo.jpg"colspan="2" valign="bottom"


style="font-style:italic">

<marquee><h1 style="color:#FFFFFF">**Belajar Website2**</h1></marquee>

<marquee><h1 style="color:#FFFFFF">NovyanaDyan</h1></marquee>

</td>

</tr>

<!--area content dan menu-->

tr>

<td width="300" height="400" bgcolor="#99CCCC" valign="top" style="font-style:italic"><h1


style="color:#FFFFFF">Menu</h1>

<img src="images/cunnn.gif" width="30" height="30">

<a href="mastermahasiswa.php">Home</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="formmahasiswa.php">Profile</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="#">About</a><br><br>

</td>

<td width="600" height="400" bgcolor="#6666CC" valign="top" style="font-style:italic">

<h1 style="color:#FFFFFF">Form Simpan</h1>

<?php

include "Koneksi.php";

$nama =$_POST['nama'];

$ttl =$_POST['ttl'];
$jk =$_POST['jk'];

$alamat =$_POST['alamat'];

$jurusan =$_POST['jurusan'];

$minat1 =$_POST['Networking'];

$minat2 =$_POST['Programing'];

$minat3 =$_POST['DesignGrafis'];

$dir_upload = "images/";

$gambar = $_FILES['photo']['name'];

mysql_query("INSERT INTO `akademik_banisaleh`.`mahasiswa` (

`id` ,

`nama` ,

`ttl` ,

`jk` ,

`alamat` ,

`jurusan` ,

`minat1` ,

`minat2` ,

`minat3` ,

`photo`

VALUES (

NULL , '$nama', '$ttl', '$jk', '$alamat', '$jurusan', '$minat1', '$minat2', '$minat3', '$gambar'

);");

?>

<?php

if(!move_uploaded_file($_FILES['photo']['tmp name'],$dir_upload.$gambar))

?>
<!--area form inputan-->

<table border="0">

<form enctype="multipart/form-data" name="FormRegistrasi" method="post">

<tr>

<td width="100">Nama</td>

<td>

<?php echo "$nama";

?></td>

</tr>

<tr>

<td width="100">TTL</td>

<td>

<?php echo "$ttl";

?></td>

</tr>

<tr>
<td width="100">Jenis Kelamin</td>

<td><?php echo "$jk";

?></td>

</td>

</tr>

<tr>

<td width="100">Alamat</td>

<td>

<?php echo "$alamat";

?></td>

</tr>

<tr>

<td width="100">Jurusan</td>

<td><?php echo "$jurusan";

?></td>

</tr>

<tr>

<td width="100" valign="top">Minat Anda</td>


<td><?php echo "$minat1 $minat2 $minat3";

?></td>

</td>

</tr>

<tr>

<td width="100">Photo</td>

<td width="100">

<img src="images/<?php echo"$gambar"?>" width="100" height="100">

</td>

</tr>

</form>

</table>

<!--area footer-->

<tr>

<td width="900" height="50" bgcolor="#FF3366" colspan="2" valign="bottom" style="font-


style:italic">

<h1 style="color:#FFFFFF">Footer</h1>

</td>

</tr>

</body>

</html>

EDIT.PHP
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Belajar website 2</title>

</head>

<!--ini block fungsi body modify 9/10/2016 by Dyan Novyana-->

<body background="images/dit.jpg">

<table border="0" align="center">

<!--area header-->

<tr>

<td width="1000" height="100" background="images/Domo.jpg"colspan="2" valign="bottom"


style="font-style:italic">

<marquee><h1 style="color:#FFFFFF">**Belajar Website2**</h1></marquee>

<marquee><h1 style="color:#FFFFFF">NovyanaDyan</h1></marquee>

</td>

</tr>

<!--area content dan menu-->

tr>

<td width="300" height="400" bgcolor="#99CCCC" valign="top" style="font-style:italic"><h1


style="color:#FFFFFF">Menu</h1>

<img src="images/cunnn.gif" width="30" height="30">

<a href="mastermahasiswa.php">Home</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="formmahasiswa.php">Profile</a><br><br>
<img src="images/cunnn.gif" width="30" height="30">

<a href="#">About</a><br><br>

</td>

<td width="600" height="400" bgcolor="#6666CC" valign="top" style="font-style:italic">

<h1 style="color:#FFFFFF">Form Simpan</h1>

<?php

include "Koneksi.php";

$id = $_GET['id'];

$tampil = mysql_query("SELECT *

FROM `mahasiswa` WHERE id = '$id' ");

$r=mysql_fetch_array($tampil);

?>

<!--area form inputan-->

<table border="0">

<form action="update.php" enctype="multipart/form-data" name="daftar" method="post">

<input type="hidden" name="id" value="<?php echo "$id"; ?>"/>

<input type="hidden" name="photolama" value="<?php echo "$r[photo]"; ?>"/>

<tr>

<td width="100">Nama</td>

<td><input type="text" name="nama" maxlength="20" value="<?php echo "$r[nama]";

?>" />

</tr>
<tr>

<td width="100">TTL</td>

<td><input type="text" name="ttl" value="<?php echo "$r[ttl]";

?>"/>

</tr>

<tr>

<td width="100">Jenis Kelamin</td><td width="50">

<?php if ("$r[jk]" == "Pria") { ?>

<input type="radio" name="jk" value="Pria" checked="checked" />PRIA<br>

<input type="radio" name="jk" value="Wanita" />WANITA<br>

<?php }else{ ?>

<input type="radio" name="jk" value="Pria"/>PRIA<br>

<input type="radio" name="jk" value="Wanita" checked="checked" />WANITA<br>

<?php } ?>

</td>

</tr>

<tr>

<td width="100">Alamat</td>

<td><textarea name="alamat" cols="30" rows="3"><?php echo "$r[alamat]";

?></textarea>

</tr>
<tr>

<td width="100">Jurusan</td>

<td><select name="jurusan">

<?php if ("$r[jurusan]" == "TI") { ?>

<option value="TI" selected="selected">Teknik Informatika</option>

<option value="SI">Sistem Informasi</option>

<option value="KA">Komputer Akuntansi</option>

<?php }if ("$r[jurusan]" == "SI"){ ?>

<option value="TI">Teknik Informatika</option>

<option value="SI" selected="selected">Sistem Informasi</option>

<option value="KA">Komputer Akuntansi</option>

<?php }if ("$r[jurusan]" == "KA"){ ?>

<option value="TI">Teknik Informatika</option>

<option value="SI">Sistem Informasi</option>

<option value="KA" selected="selected">Komputer Akuntansi</option>

<?php } ?>

</select>

</td>

</tr>

<tr>

<td width="100">Peminatan</td>

<td><?php if ("$r[minat1]" == "Networking") { ?>

<input type="checkbox" name="Networking" value="Networking" checked="checked" />Network

<?php }else{ ?>

<input type="checkbox" name="Networking" value="Networking"/>Network

<?php } ?>
</td>

</tr>

<tr>

<td width="100"></td>

<td><?php if ("$r[minat2]" == "Programing") { ?>

<input type="checkbox" name="Programing" value="Programing" checked="checked" />Programing

<?php }else{ ?>

<input type="checkbox" name="Programing" value="Programing"/>Programing

<?php } ?>

</td>

</tr>

<tr>

<td width="100"></td>

<td><?php if ("$r[minat3]" == "DesignGrafis") { ?>

<input type="checkbox" name="DesignGrafis" value="DesignGrafis" checked="checked"/>Design


Grafis

<?php }else{ ?>

<input type="checkbox" name="DesignGrafis" value="DesignGrafis"/>Design Grafis

<?php } ?>

</td>

</tr>

<tr>

<td width="100">Photo</td>

<td><input name="photo" type="file"/>


</td>

</tr>

<tr>

<td width="100"></td>

<td><input type="submit" name="Save" value="save"/>

</td>

</tr>

</form>

</table>

<!--area footer-->

<tr>

<td width="900" height="50" bgcolor="#FF3366" colspan="2" valign="bottom" style="font-


style:italic">

<h1 style="color:#FFFFFF">Footer</h1>

</td>

</tr>

</body>

</html>

UPDATE.PHP

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Belajar website 2</title>


</head>

<!--ini block fungsi body modify 9/10/2016 by Dyan Novyana-->

<body background="images/dit.jpg">

<table border="0" align="center">

<!--area header-->

<tr>

<td width="1000" height="100" background="images/Domo.jpg"colspan="2" valign="bottom"


style="font-style:italic">

<marquee><h1 style="color:#FFFFFF">**Belajar Website2**</h1></marquee>

<marquee><h1 style="color:#FFFFFF">NovyanaDyan</h1></marquee>

</td>

</tr>

<!--area content dan menu-->

tr>

<td width="300" height="400" bgcolor="#99CCCC" valign="top" style="font-style:italic"><h1


style="color:#FFFFFF">Menu</h1>

<img src="images/cunnn.gif" width="30" height="30">

<a href="mastermahasiswa.php">Home</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="formmahasiswa.php">Profile</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="#">About</a><br><br>

</td>

<td width="600" height="400" bgcolor="#6666CC" valign="top" style="font-style:italic">


<h1 style="color:#FFFFFF">Form Simpan</h1>

<!--area form inputan-->

<table border="0">

<?php

include "Koneksi.php";

$id = $_POST['id'];

$photolama = $_POST['photolama'];

$nama =$_POST['nama'];

$ttl =$_POST['ttl'];

$jk =$_POST['jk'];

$alamat =$_POST['alamat'];

$jurusan =$_POST['jurusan'];

$minat1 =$_POST['Networking'];

$minat2 =$_POST['Programing'];

$minat3 =$_POST['DesignGrafis'];

$dir_upload = "images/";

$gambar = $_FILES['photo']['name'];

if ($gambar == ""){

$gambar = "$photolama";

};
mysql_query("UPDATE mahasiswa SET nama='$nama', ttl='$ttl', jk='$jk', alamat='$alamat',
jurusan='$jurusan', jurusan='$jurusan', minat1='$minat1', minat2='$minat2', minat3='$minat3',
photo='$gambar' WHERE id = '$id';");

?>

<tr>

<td width="100">Nama</td>

<td>

<?php echo "$nama";

?></td>

</tr>

<tr>

<td width="100">TTL</td>

<td>

<?php echo "$ttl";

?></td>

</tr>

<tr>

<td width="100">Jenis Kelamin</td>

<td><?php echo "$jk";

?></td>

</td>
</tr>

<tr>

<td width="100">Alamat</td>

<td>

<?php echo "$alamat";

?></td>

</tr>

<tr>

<td width="100">Jurusan</td>

<td><?php echo "$jurusan";

?></td>

</tr>

<tr>

<td width="100" valign="top">Minat Anda</td>

<td><?php echo "$minat1 $minat2 $minat3";

?></td>

</td>

</tr>

<?php
if(!move_uploaded_file($_FILES['photo']['tmp name'],$dir_upload.$gambar))

?>

<tr>

<td width="100">Photo</td>

<td width="100">

<img src="images/<?php echo"$gambar"?>" width="100" height="100">

</td>

</tr>

</table>

<!--area footer-->

<tr>

<td width="900" height="50" bgcolor="#FF3366" colspan="2" valign="bottom" style="font-


style:italic">

<h1 style="color:#FFFFFF">Footer</h1>

</td>

</tr>

</body>

</html>

HAPUS.PHP

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Belajar website 2</title>

</head>
<!--ini block fungsi body modify 9/10/2016 by Dyan Novyana-->

<body background="images/dit.jpg">

<table border="0" align="center">

<!--area header-->

<tr>

<td width="1000" height="100" background="images/Domo.jpg"colspan="2" valign="bottom"


style="font-style:italic">

<marquee><h1 style="color:#FFFFFF">**Belajar Website2**</h1></marquee>

<marquee><h1 style="color:#FFFFFF">NovyanaDyan</h1></marquee>

</td>

</tr>

<!--area content dan menu-->

tr>

<td width="300" height="400" bgcolor="#99CCCC" valign="top" style="font-style:italic"><h1


style="color:#FFFFFF">Menu</h1>

<img src="images/cunnn.gif" width="30" height="30">

<a href="mastermahasiswa.php">Home</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="formmahasiswa.php">Profile</a><br><br>

<img src="images/cunnn.gif" width="30" height="30">

<a href="#">About</a><br><br>

</td>

<td width="600" height="400" bgcolor="#6666CC" valign="top" style="font-style:italic">


<h1 style="color:#FFFFFF">Form Simpan</h1>

<table border="0">

<?php

include "Koneksi.php";

$id =$_GET['id'];

mysql_query("DELETE

FROM mahasiswa WHERE id = '$id' ");

echo "Data Berhasil di hapus";

?>

</table>

<!--area footer-->

<tr>

<td width="900" height="50" bgcolor="#FF3366" colspan="2" valign="bottom" style="font-


style:italic">

<h1 style="color:#FFFFFF">Footer</h1>

</td>

</tr>

</body>

</html>

You might also like