You are on page 1of 7

Script Koneksi <?php mysql_connect('localhost:3434','root',''); mysql_select_db('penilaian_siswa'); ?

> Form Bidang Studi

Script form bidang studi <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="600" border="1"> <tr> <td colspan="3">&nbsp;</td> <td align="center"><a href="tambah_bidangstudi.php">Tambah Data</a></td> </tr> <tr> <td width="142" align="center">Kode Bidang</td> <td width="215" align="center">Nama Bidang</td> <td width="220" align="center">ubah</td> <td width="195" align="center">hapus</td> </tr> <?php //memanggil koneksi include"koneksi.php"; //menampilkan data dari tabel bidang studi $tampil="select * from bidang_studi"; $query=mysql_query($tampil) or die("Gagal Tampil".mysql_error()); while($data=mysql_fetch_array($query)){ ?> <tr> <td><?php echo"$data[bidang_kode]";?></td> <td><?php echo"$data[bidang_nama]";?></td> <td><a href="ubah_bidangstudi.php?idubah=<?php echo"$data[bidang_kode]";?>">ubah</a></td> <td><a href="hapus_bidangstudi.php?idhapus=<?php echo"$data[bidang_kode]";?>" onclick="return confirm('Anda Yakin Akan Menghapus ')">Hapus</a></td> </tr>

<?php }?> </table> </body> </html> Script hapus <?php //memanggil koneksi include"koneksi.php"; $idhapus=$_GET['idhapus']; //hapus data dari tabel bidang studi $hapus="delete from bidang_studi where bidang_kode='$idhapus'"; $query=mysql_query($hapus) or die("GAGAL hapus".mysql_error()) echo"data berhasil di hapus"; include"bidang_studi.php"; ?> Form ubah

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <body> <?php // mendeklarasikan variabel ubah $idubah=$_GET['idubah']; //memanggil koneksi include"koneksi.php"; //menampilkan data dari tabel bidang studi $tampil="select * from bidang_studi where bidang_kode='$idubah'";

$query=mysql_query($tampil) or die("Gagal Tampil".mysql_error()); $data=mysql_fetch_array($query); ?> <form id="form1" name="form1" method="post" action="simpanubah_bidangstudi.php"> <table width="500" border="1" align="center"> <tr> <td colspan="2" align="center">Form Bidang Studi</td> </tr> <tr> <td width="120">Kode Bidang</td> <td width="364"><span id="sprytextfield1"> <input type="text" name="kode" id="kode" value="<?php echo"$data[bidang_kode]";?>" disabled="disabled" /> <span class="textfieldRequiredMsg">A value is required.</span></span> <input type="hidden" name="kode" id="kode2" value="<?php echo"$data[bidang_kode]";?>" /></td> </tr> <tr> <td>Nama Bidang</td> <td><span id="sprytextfield2"> <input type="text" name="nama" id="nama" value="<?php echo"$data[bidang_nama]";?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td>&nbsp;</td> <td><input type="submit" name="button" id="button" value="Simpan Data" /></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> </form> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); </script> </body> </html> Script simpan ubah <?php //memanggil koneksi include"koneksi.php"; //mendeklarasikan variabel

$kode=$_POST['kode']; $nama=$_POST['nama']; //menyimpan data ke tabel bidang studi $simpan="update bidang_studi set bidang_nama='$nama' where bidang_kode='$kode'"; $query=mysql_query($simpan) or die("Gagal simpan".mysql_error()); echo"Data berhasil di ubah"; include"bidang_studi.php"; ?> Form tambah

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" name="form1" method="post" action="simpan_bidangstudi.php"> <table width="500" border="1" align="center"> <tr> <td colspan="2" align="center">Form Bidang Studi</td> </tr> <tr> <td width="120">Kode Bidang</td> <td width="364"><span id="sprytextfield1"> <input type="text" name="kode" id="kode" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td>Nama Bidang</td> <td><span id="sprytextfield2"> <input type="text" name="nama" id="nama" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td>

</tr> <tr> <td>&nbsp;</td> <td><input type="submit" name="button" id="button" value="Simpan Data" /></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> </form> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); </script> </body> </html> Script Simpan <?php //memanggil koneksi include"koneksi.php"; //mendeklarasikan variabel $kode=$_POST['kode']; $nama=$_POST['nama']; //menyimpan data ke tabel bidang studi $simpan="insert into bidang_studi(bidang_kode,bidang_nama) values('$kode','$nama')"; $query=mysql_query($simpan) or die("Gagal simpan".mysql_error()); echo"Data berhasil di simpan"; include"bidang_studi.php"; ?> Script simpanubah <?php //memanggil koneksi include"koneksi.php"; //mendeklarasikan variabel $kode=$_POST['kode']; $nama=$_POST['nama']; //menyimpan data ke tabel bidang studi $simpan="update bidang_studi set bidang_nama='$nama' where bidang_kode='$kode'";

$query=mysql_query($simpan) or die("Gagal simpan".mysql_error()); echo"Data berhasil di ubah"; include"bidang_studi.php"; ?> Form login index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" name="form1" method="post" action="loginsubmit.php"> <p>&nbsp;</p> <table width="400" border="1" align="center"> <tr> <td width="185">Username</td> <td width="199"><span id="sprytextfield1"> <input type="text" name="username" id="username" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td>Password</td> <td><span id="sprypassword1"> <input type="password" name="password" id="password1" /> <span class="passwordRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td>&nbsp;</td>

<td><input type="submit" name="button" id="button" value="Login" /></td> </tr> </table> <p>&nbsp;</p> </form> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1"); </script> </body> </html> Script Login <?php session_start(); //memanggil koneksi include"koneksi.php"; //mendeklarasikan variabel $username=$_POST['username']; $password=$_POST['password']; //menampilkan data dari tabel user sesuai dengan $username $tampil="select * from user where username='$username'"; $query=mysql_query($tampil) or die("Gagal tampil".mysql_error()); $data=mysql_fetch_array($query); if($password == $data['password']){ $_SESSION['username']=$username; header('Location: home.php'); } else { echo"gagal Login"; include"index.php"; } ?> Script Logout <?php session_start(); session_destroy(); include"index.php"; ?>

You might also like