modkrs.php
<?
session_start();
include "config/koneksi.php";
$PRODI_MHS=$_SESSION['KDPRODI'];
$prodi=mysql_query ("select * from prodi where KDPRODI='$PRODI_MHS'");
$bln_sekarang=date("m");
$operator = '!=';
if($bln_sekarang < 6){ //genap
$operator = '=';
}
if (sem==$operator && prodi==$PRODI_MHS){
echo "$operator";
}
$sql =mysql_query ("select * from makul inner join jadwal1 on jadwal1.KDMKM=makul.KDMKM where SEMES % 2 $operator 0 order by SEMES asc");
while($k=mysql_fetch_array($sql)){
$kode[]=$k['KDMKM'];
$nama[]=$k['NAKMK'];
$hari[]=$k['HARI'];
$jam[]=$k['JAM'];
$nidn[]=$k['NIDN'];
$sks[] = $k['SKSMK'];
$semester[]=$k['SEMES'];
$ruang[]=$k['KDRUANG'];
$prodi[]=$k['KDPRODI'];
}
?>
<html>
<head>
<title>Check Box KRS</title>
<script>
<?php
echo "var jumlah = ".count($kode).";\n";
echo "var sks = new Array();\n";
//mengambil sks matakuliah dan memasukkan ke array javascript
for($j=0;$j<count($kode);$j++){
echo "sks['".$kode[$j]."'] = ".$sks[$j].";\n";
}
?>
function hitungtotal(){
jum = 0;
for(i=0;i<jumlah;i++){
id = "mk"+i;
td1 = "k1"+i;
td2 = "k2"+i;
td3 = "k3"+i;
td4 = "k4"+i;
if(document.getElementById(id).checked){
kode = document.getElementById(id).value
jum = jum + sks[kode];
//untuk mengubah warna latar tabel apabila diceklist
document.getElementById(td1).style.backgroundColor = "white";
document.getElementById(td2).style.backgroundColor = "white";
document.getElementById(td3).style.backgroundColor = "white";
document.getElementById(td4).style.backgroundColor = "white";
}else {
document.getElementById(td1).style.backgroundColor = "white";
document.getElementById(td2).style.backgroundColor = "white";
document.getElementById(td3).style.backgroundColor = "white";
document.getElementById(td4).style.backgroundColor = "white";
}
}
//menampilkan total jumlah SKS yang diambil
document.getElementById("jsks").innerHTML = jum;
}
</script>
</head>
<body>
<?php
$query="SELECT * from mhs inner join prodi on mhs.KDPRODI=prodi.KDPRODI where NIMHS='".$_SESSION['NIMHS']."'";
$result=mysql_query($query);
$data=mysql_fetch_array($result);
// cari tahun sekarang dan bulan sekarang
$bln_sekarang=date("m");
//juka bukan sekarang lebih dari bukan ke 5 dan kurang dari bulan ke 13
if($bln_sekarang >05 and $bln_sekarang<=12){
$thn_sekarang .="2";
$sem="Gasal";
}else{
$thn_sekarang .="1";
$sem="Genap";
}
echo"<table width=\"500\" cellspacing=5 border=\"0\"><tr><td rowspan=\"5\" valign=\"top\" align=\"justify\">
<tr>
<td>Nama</td><td>: $data[NMMHS]</td>";
echo "<td>NIM</td><td>: $data[NIMHS]</td></tr>";
$tahun=date("Y");
$th1=$tahun+1;
echo"<tr><td>Semester</td><td>: $sem ($data[KDSEMES]) $tahun/$th1</td>
<td>Program Studi</td><td>: $data[PRODI]</td>
</tr>";
$ip = mysql_query("select * from nilai WHERE NIMHS = '$_SESSION[NIMHS]'");
while($l = mysql_fetch_array($ip)){
$ipnya = $l['IPS'];
if($ipnya>=3){
$sks_dptdiambil="24 sks";
}
elseif($ipnya>=2.5 and $ipnya<3){
$sks_dptdiambil="21 sks";
}
elseif($ipnya>=2 and $ipnya<2.5){
$sks_dptdiambil="18 sks";
}
elseif($ipnya>=1.5 and $ipnya<2){
$sks_dptdiambil="15 sks";
}
else{
$sks_dptdiambil="12 sks";
}
echo "<tr>";
echo "<td >Ip Sebelumnya</td><td>: $ipnya</td>";
echo "<td >Jumlah SKS Y.A.D</td><td>: $sks_dptdiambil";
echo "</td></tr></table>";
}
?>
<p><form name="formkrs" method="POST" action="index1.php?hal=inputkrs">
<table border=1 width=570 style="border-collapse:collapse" bordercolor="#999999">
<tr><td><b>Kode</b></td>
<td><b>Nama Mata Kuliah</b></td><td><b>HARI</b></td>
<td align="center"><b>JAM</b></td>
<td align="center"><b>SKS</b></td>
<td align="center"><b>NIDN</b></td>
<td align="center"><b>SEMESTER</b></td>
<td align="center"><b>RUANG</b></td><td align="center"><b>PRODI</b></td>
<td align="center"><b>Ambil</b></td></tr>
<?php
//menampilkan matakuliah ke dalam tabel
for($i=0;$i<count($kode);$i++){
echo "<tr><td id=k1$i>".$kode[$i]."</td>";
echo "<td id=k2$i>".$nama[$i]."</td>";
echo "<td align='center'>".$hari[$i]."</td>";
echo "<td id=k2$i>".$jam[$i]."</td>";
echo "<td align='center' id=k3$i>".$sks[$i]."</td>";
echo "<td align='center' id=k3$i>".$nidn[$i]."</td>";
echo "<td align='center' id=k3$i>".$semester[$i]."</td>";
echo "<td align='center' id=k3$i>".$ruang[$i]."</td>";
echo "<td align='center' id=k3$i>".$prodi[$i]."</td>";
echo "<td align='center' id=k4$i><input type=checkbox name=mk[] onclick=hitungtotal()
value=".$kode[$i]." id=mk".$i."></tr>";
}
?>
<tr><td colspan=8>JUMLAH YANG DIAMBIL</td><td align="center">
<span id=jsks></span></td></tr>
</table>
<br/>
<input name="kirim" type="submit" value="Kirim KRS">
</form>
</body>
</html>
cekloginmhs.php
[code=php]
<?php
include "config/koneksi.php";
$pass=md5($_POST[password]);
$login=mysql_query("SELECT * FROM mhs WHERE NIMHS='$_POST[NIMHS]' AND password='$pass' and STUANG='L'");
$ketemu=mysql_num_rows($login);
$r=mysql_fetch_array($login);
// Apabila username dan password ditemukan
if ($ketemu > 0){
session_start();
session_register("namauser");
session_register("passuser");
$_SESSION[NMMHS] = $r[NMMHS];
$_SESSION[NIMHS] = $r[NIMHS];
$_SESSION[SEMESTER] = $r[KDSEMES];
$_SESSION[PRODI_MHS]=$r[KDPRODI];
$_SESSION[namauser] = $r[username];
$_SESSION[passuser] = $r[password];
?> <script language="javascript">
alert("Anda Berhasil login");
document.location="index1.php?hal=homemhs";
</script>
<?
} else {
?>
<script language="javascript">
alert("Login Anda tidak diterima, cek NIM atau password anda kembali atau hubungi BAUK !!");
document.location="index.php?hal=logmhs";
</script>
<?
}
?>