Pemrograman Web 2. Modul 6. Form Pengambilan KRS dengan menggunakan PHP + MYSql

1. File Pengambi2lan KRS  : Formkrs.html
4checks.com-Free Shipping and Handling on All Personal Checks with code DWF008


<html>
<body>
<h3>Input KRS</h3>
<table border=1>
<form method=post action="tampilkrs.php">
<tr><td>
No BP    </td><td>=<input type=text name="nobp"</td></tr>
<tr><td>
Semester </td><td>=<input type=text name="semester"</td></tr>
<tr><td>
Tahun    </td><td>=<input type=text name="tahun"</td></tr>
<tr><td>
<input type =submit value="OK">
<input type=reset value ="Cancel"></td></tr>
</form>
</body>
</html>

2.  tampilkrs.php


<?php
include "konek.php";
$NOBP=$_POST['nobp'];
$semester =$_POST['semester'];
$tahun =$_POST['tahun'];

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

$sqlmhs=mysql_query("select * from mhs where nobp='$NOBP'");
$datamhs=mysql_fetch_row($sqlmhs);

echo "<tr><td colspan=4>NO BP=$datamhs[0]<br>";
echo "Nama     =$datamhs[1]<br>";
echo "Semester =$semester<br>";
echo "Tahun    =$tahun<br></tr><td>";

//set cookie
setcookie("NOBP",$NOBP);
setcookie("namamhs",$datamhs[1]);
setcookie("semester",$semester);
setcookie("tahun",$tahun);
?>

<html>
<body>
<form method=post action=inputkrs.php>
<tr>
 <th>kode</th>
 <th>Nama Matakuliah </th>
 <th>SKS</th>
 <th>Ambil </th></tr>
<?php
$sqlmtk=mysql_query("select * from mtk");
while($data2=mysql_fetch_array($sqlmtk))
{
 echo "<tr><td>$data2[kode]</td>";
 echo "<td>$data2[nama]</td>";
 echo "<td>$data2[sks]</td>";
 echo "<td><input type=checkbox name=kode[]
 value=$data2[kode]></tr>";
}
?>
<tr><td colspan=4><input type=submit Value="OK">
<input type=reset Value="Cancel"><td></tr>
</table>
</form>
</body>
</html>

3. inputkrs.php

)){

$nobp= $_COOKIE['NOBP'];
$namamhs=$_COOKIE['namamhs'];
$semester= $_COOKIE['semester'];
$tahun = $_COOKIE['tahun'];

$cek = mysql_query("select * from krs where nobp='$nobp'
 AND semester='$semester' AND tahun='$tahun'");
$hasil=mysql_num_rows($cek);
if($hasil > 0 )
{
 die("sudah pernah input");
}
echo"<table border=1>";
foreach($_POST['kode'] as $valkode){
 mysql_query("insert into krs (nobp,kodemk,semester,tahun) values ('$nobp','$valkode','$semester','$tahun')");
}
echo"<tr><td colspan=4>NOBP : $nobp<br>";
echo"Nama : $namamhs<br>";
echo"Semester : $semester<br>";
echo"Tahun : $tahun<br></td></tr>";
?>

<tr>  <th>No.</th>
 <th>Kode</th>
 <th>Nama Matakuliah</th>
 <th>SKS</th>
</tr>
<?php
$sqlkrs = mysql_query("SELECT * FROM krs, mtk WHERE nobp='$nobp'
 AND krs.kodemk = mtk.kode
 AND krs.semester='$semester' AND krs.tahun='$tahun'");
$jumsks = 0;
$i = 1;
while($datakrs = mysql_fetch_array($sqlkrs)){
 echo "<tr><td>$i</td>";
 echo "<td>$datakrs[kode]</td>";
 echo "<td>$datakrs[nama]</td>";
 echo "<td>$datakrs[sks]</td></tr>";
 $jumsks = $jumsks + $datakrs['sks'];
 $i++;
}
echo "<tr><td colspan=3>JUMLAH</td><td>$jumsks</td></tr>";
?>
</table>

Materi yang berhubungan :

1. Aplikasi Sistem Informasi Akademik
2. Form MAhasiswa
3. Form Dosen
4. Form Matakuliah
5. Jadwal Perkuliahan"
6. Form KRS
7. Form Nilai
8. Form LHS

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

%d bloggers like this: