Tugas 1 Pemrograman Web Dinamis

Tampilan View

tampilan view

Tampilan Insert

tampilan insertTampilan Edit

edit
Source koneksi.php

<!--?php mysql_connect('localhost','root',''); mysql_select_db('ukmkarate'); ?-->

Script Index.php

<!--?php include"koneksi.php";?-->
Form Pendaftaran UKM Karate UAD
		<link href="assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/bootstrap-responsive.css" rel="stylesheet" /></pre>
<div class="box_judul">Pendaftaran Anggota UKM Karate UAD</div>
<div class="tabbable" style="margin-bottom: 18px; margin-top: 100px;">
<ul class="nav nav-tabs">
	<li><a href="#tab1" data-toggle="tab">Insert</a></li>
	<li class="active"><a href="#tab2" data-toggle="tab">View</a></li>
</ul>
<div class="tab-content" style="padding-bottom: 9px; border-bottom: 1px solid #ddd;"></div>
</div>
<pre><!-- JAVASCRIPT -->
<script type="text/javascript" src="assets/js/jquery.js"></script><script type="text/javascript" src="assets/js/bootstrap-transition.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-alert.js"></script><script type="text/javascript" src="assets/js/bootstrap-modal.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-dropdown.js"></script><script type="text/javascript" src="assets/js/bootstrap-scrollspy.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-tab.js"></script><script type="text/javascript" src="assets/js/bootstrap-tooltip.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-popover.js"></script><script type="text/javascript" src="assets/js/bootstrap-button.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-collapse.js"></script><script type="text/javascript" src="assets/js/bootstrap-typeahead.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-affix.js"></script><script type="text/javascript" src="assets/js/holder/holder.js"></script>
<script type="text/javascript" src="assets/js/google-code-prettify/prettify.js"></script><script type="text/javascript" src="assets/js/application.js"></script>
<!-- JAVASCRIPT -->

Source View.php

</pre>
NIMNamaEmailProdiAlamat AsalAlamat JogjaNo TelpAction }else{ echo'<b>GAGAL MENGAMBIL DATA</b>'; } ?>
<table class="table table-bordered">
<thead></thead>
<tbody><!--?php  $ambil=mysql_query("SELECT * FROM anggota ORDER BY nim ASC"); if($ambil!=NULL){ while($cetak=mysql_fetch_array($ambil)){  ?-->
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><a href="update.php?id=<?php echo $cetak['nim'] ?>"><button class="btn btn-primary">Edit</button></a>
 <a href="aksi.php?act=hapus&id=<?php echo $cetak['nim'] ?>"><button class="btn btn-danger">Hapus</button></a></td>
</tr>
<!--?php }<br ?--></tbody>
</table>
<pre>

Source Edit.php


<!--?php  $query=mysql_query("SELECT * FROM anggota WHERE nim=".$_GET['id'].""); if($query!=NULL){ $ambil=(mysql_fetch_array($query)); ?--></pre>
<form class="form-horizontal" action="aksi.php?act=update&id=<?php echo $ambil['nim'] ?><br />" method="post">
<div class="control-group"><label class="control-label">NIM</label>
<div class="controls"><input id="inputNIM" type="text" name="fnim" required="required" value="<?php echo $ambil['nim']; ?>" /></div>
</div>
<div class="control-group"><label class="control-label">Nama</label>
<div class="controls"><input id="inputNama" type="text" name="fnama" required="required" value="<?php echo $ambil['nama']; ?>" /></div>
</div>
<div class="control-group"><label class="control-label" for="inputPassword">Password</label>
<div class="controls"><input id="inputPassword" type="password" name="fpassword" required="required" value="<?php echo $ambil['password']; ?>" /></div>
</div>
<div class="control-group"><label class="control-label" for="inputEmail">Email</label>
<div class="controls"><input id="inputEmail" type="text" name="femail" required="required" value="<?php echo $ambil['email']; ?>" /></div>
</div>
<div class="control-group"><label class="control-label">Prodi</label>
<div class="controls">
<select name="fprodi"><optgroup label="FAI"><option selected="selected" value="Tafsir Hadist">>Tafsir Hadis</option><option selected="selected" value="Bhs dan Sastra Arab">>Bahasa dan Sastra Arab</option></optgroup></select>

<select name="fprodi"><optgroup label="FE"><option selected="selected" value="Ekonomi Pembangunan">>Ekonomi Pembangunan</option><option selected="selected" value="Akuntansi">>Akuntansi</option><option selected="selected" value="Manajemen">>Manajemen</option></optgroup></select>

<select name="fprodi"><optgroup label="F Far"><option selected="selected" value="Farmasi">>Farmasi</option><option selected="selected" value="Program Profesi Apoteker">>Program Profesi Apoteker</option></optgroup></select>

<select name="fprodi"><optgroup label="FH"><option selected="selected" value="Ilmu Hukum">>Ilmu Hukum</option></optgroup></select>

<select name="fprodi"><optgroup label="FKIP"><option selected="selected" value="Bimbingan Konseling">>Bimbingan Konseling</option><option selected="selected" value="Pend. Sastra dan Bahasa Indonesia">>Pendidikan Sastra dan Bahasa Indonesia</option><option selected="selected" value="Pend. Bhs Inggris">>Pendidikan Bahasa Inggris</option><option selected="selected" value="Pend. Matematika">>Pendidikan Matematika</option><option selected="selected" value="Pend. Fisika">>Pendidikan Fisika</option><option selected="selected" value="Pend. Biologi">>Pendidikan Biologi</option><option selected="selected" value="Pend. Pancasila dan Kewarganegaraan">>Pendidikan Pancasila dan Kewarganegaraan</option><option selected="selected" value="PGSD">>Pendidikan Guru Sekolah Dasar</option><option selected="selected" value="PGPAUD">>Pendidikan Guru PAUD</option><option selected="selected" value="PGBI-MIPA Pend. Biologi">>PGBI-MIPA Pendidikan Biologi</option><option selected="selected" value="PGBI-MIPA Pend. Fisika">>PGBI-MIPA Pendidikan Fisika</option><option selected="selected" value="PGBI-MIPA Pend. Matematika">>PGBI-MIPA Pendidikan Matematika</option></optgroup></select>

<select name="fprodi"><optgroup label="FKM"><option selected="selected" value="Ilmu Kesehatan Masyarakat">>Ilmu Kesehatan Masyarakat</option></optgroup></select>

<select name="fprodi"><optgroup label="FMIPA"><option selected="selected" value="Matematika">>Matematika</option><option selected="selected" value="Fisika">>Fisika</option><option selected="selected" value="Sistem Informasi">>Sistem Informasi</option><option selected="selected" value="Biologi">>Biologi</option></optgroup></select>

<select name="fprodi"><optgroup label="F Psi"><option selected="selected" value="Psikologi">>Psikologi</option></optgroup></select>

<select name="fprodi"><optgroup label="FSBIK"><option selected="selected" value="Sastra Inggris">>Sastra Inggris</option><option selected="selected" value="Sastra Indonesia">>Sastra Indonesia</option><option selected="selected" value="Ilmu Komunikasi">>Ilmu Komunikasi</option></optgroup></select>

<select name="fprodi"><optgroup label="FTI"><option selected="selected" value="Tek. Industri">>Teknik Industri</option><option selected="selected" value="Tek. Informatika">>Teknik Informatika</option><option selected="selected" value="Tek. Kimia">>Teknik Kimia</option><option selected="selected" value="Tek. Elektro">>Teknik Elektro</option></optgroup></select>

</div>
</div>
<div class="control-group"><label class="control-label">Alamat Asal</label>
<div class="controls"><input id="inputAS" type="text" name="falamatasal" required="required" value="<?php echo $ambil['alamat_asal']; ?>" /></div>
</div>
<div class="control-group"><label class="control-label">Alamat Jogja</label>
<div class="controls"><input id="inputAJ" type="text" name="falamatjogja" required="required" value="<?php echo $ambil['alamat_jogja']; ?>" /></div>
</div>
<div class="control-group"><label class="control-label">No Telp</label>
<div class="controls"><input id="inputTelp" type="text" name="fnotelp" required="required" value="<?php echo $ambil['no_telp']; ?>" /></div>
</div>
<div class="control-group">
<div class="controls"><button class="btn" type="submit">Submit</button>
 <a class="btn" href="javascript:history.back()">Back</a></div>
</div>
</form>
<pre>
<!--?php }else{<br ?-->	echo'</pre>
<center><b>Gagal Mengambil Data</b></center>
<pre>';
	}?>

Source aksi.php

<!--?php <br ?-->include"koneksi.php";

$aksi=$_GET['act'];

if($aksi=='insert'){

$vnim=$_POST['fnim'];
$vnama=$_POST['fnama'];
$vpassword=md5($_POST['fpassword']);
$vemail=$_POST['femail'];
$vprodi=$_POST['fprodi'];
$valamat_asal=$_POST['falamatasal'];
$valamat_jogja=$_POST['falamatjogja'];
$vno_telp=$_POST['fnotelp'];

	$query=mysql_query("INSERT INTO anggota (
	nim,
	nama,
	password,
	email,
	prodi,
	alamat_asal,
	alamat_jogja,
	no_telp
	) VALUES (	'$vnim',
	'$vnama',
	'$vpassword',
	'$vemail',
	'$vprodi',
	'$valamat_asal',
	'$valamat_jogja',
	'$vno_telp'
	)");

if($query){
	header('location:index.php');
	}else{
	echo'</pre>
<center>GAGAL MENYIMPAN DATA</center>
<pre>';
	}

}else if($aksi=='update'){

$vnim=$_POST['fnim'];
$vnama=$_POST['fnama'];
$vpassword=md5($_POST['fpassword']);
$vemail=$_POST['femail'];
$vprodi=$_POST['fprodi'];
$valamat_asal=$_POST['falamatasal'];
$valamat_jogja=$_POST['falamatjogja'];
$vno_telp=$_POST['fnotelp'];

	$query=mysql_query("UPDATE anggota SET
	nim='$vnim',
	nama='$vnama',
	password='$vpassword',
	email='$vemail',
	prodi='$vprodi',
	alamat_asal='$valamat_asal',
	alamat_jogja='$valamat_jogja',
	no_telp='$vno_telp'
	WHERE nim=".$_GET['id']."");

if($query){
	header('location:index.php');
	}else{
	echo'</pre>
<center>GAGAL MENYIMPAN DATA</center>
<pre>';
	}

}else if($aksi=='hapus'){
	$query=mysql_query("DELETE FROM anggota
	WHERE nim=".$_GET['id']."");

if($query){
	header('location:index.php');
	}else{
	echo'</pre>
<center>GAGAL MENYIMPAN DATA</center>
<pre>';
	}

}
?>

Download Sourcecode Di Sini

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s