Perancangan Sistem Pakar Untuk Mendiagnosa Kerusakan Handphone Dengan Metode Certainty Factor (Cf) Berbasis Web
LISTING PROGRAM 1.
Index.php (Halaman Index)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sistem Pakar Certainty Factor</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="header"> <div class="wrap"><strong>Sistem Pakar untuk Mendiagnosa Kerusakan Handphone dengan Metode <em>Certainty Factor</em></strong><em></em></div></div> <div id="headerpic"> <img src="pics/nokia 6600-2.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/Nokia-6600-Reviews.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/nokia6610.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6610_pic2.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6630.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/nokia6630-2.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/Nokia_6670.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/nokia_6670_L_01.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/n6680_main1.jpg" title="Nokia 6680" class="headerpic" /> <img src="pics/nokia6680.jpg" title="Nokia 6680" class="headerpic" /> </div> <div id='menu'> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer #in case user has come for first time and cookies are not set then if (!isset($_COOKIE['username'])) { echo "<form action='check_login.php' method='post' name='formlogin'> <table width='307' height='58' border='0'> <tr> <td width='69'>Username</td> <td width='10'>:</td> <td width='153'><input type='text' name='loginusername' id='username' /></td> <td width='345'></td>
<tr> <td>Password</td> <td>:</td> <td><input type='password' name='loginpass' id='loginpass' /></td> <td><input type='submit' name='login' id='login' value='Login' /></td> </tr>
</form> <tr> <td colspan='4'>"; if ($_GET['err'] == "1") { echo " <p style=color:red; > Harap isi username dan password anda. </p>"; } else if ($_GET['err'] == "2") { echo " <p style=color:red; > Username atau password salah. </p>"; } else if ($_GET['err'] == "3") { echo " <p style=color:red; > Harap login kembali. </p>"; } else if ($_GET['notice'] == "1") { echo " <p style=color:red; > Anda telah berhasil log out. </p>"; } echo "</td> </tr> </table>"; } //if cookies are set then use them else{ echo "<table width='307' height='58' border='0'> <tr> <td align='justify'><b>Welcome " . $_COOKIE["username"] . "</b> </td> </tr></table>"; } ?> <!-- menu list --> <label for="list_menu"></label> <table width="139" border="0" align="left"> <tr align='left'> <td><?php if (isset($_COOKIE['username']))
{ echo "<form action='logout.php' method='post'> <input type='submit' value='Log Out' /></form>";
} ?></td> </tr>
<td><?php if (isset($_COOKIE['type'])) { if ($_COOKIE['type'] == 'Admin' || $_COOKIE['type'] == 'Pakar')
{ echo "<form action='list_hp.php' method='post'> <input type='submit' value='List HP' /></form></td> </tr> <tr align='left'> <td><form action='list_gejala.php' method='post'> <input type='submit' value='List Gejala' /></form></td> </tr> <tr align='left'> <td>";
} if ($_COOKIE['type'] == 'Admin') { echo "<form action='list_member.php' method='post'>
<input type='submit' value='List Member' /></form>"; } } ?> </td>
</tr> <tr align='left'> <td><form action='about.php' method='post'> <input type='submit' value='About' /></form></td> </tr> <tr> <td></td> </tr> </table> </div> <div id="content"> <p>Untuk mulai mendiagnosa kerusakan handphone anda, silahkan pilih tipe handphone anda terlebih dahulu:</p> <form method="GET" action="process.php"> <select name="type_hp" > <?php
$tbl_name="hp"; $sql = "SELECT DISTINCT Type_hp FROM $tbl_name ORDER BY Type_hp"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){
?> <option value="<?php echo $rows['Type_hp'];?>"> <?php echo
$rows['Type_hp']; ?></option> <?php
} echo "<input type='submit' value='Lanjutkan' />"; echo "</form>"; if ($_GET['err'] == "4") { echo " <p style=color:red; > Type HP salah. </p>"; } ?> </div> <div class ="wrap1"> </div> <div class ="wrap1"> </div> <div id="footer"> <div class ="wrap"> <p>&copy; 2015 - Nico Junari</p> </div></div> </body> </html> 2.
Process.php (Halaman Proses)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Processing</title> </head> <body> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer $bgclr = "#00FF66"; //check if field is empty,if yes,return to index if ($_GET['type_hp'] == null ) { header('location:index.php?err=4'); exit();
} $type_hp=$_GET['type_hp']; // To protect against MySQL injection $type_hp = stripslashes($type_hp); $type_hp = mysql_real_escape_string($type_hp); $tbl="hp"; $typeh = str_replace(' ','',$type_hp); $tblaturan="aturan".$typeh; $tbl2="gejala";
$result=mysql_query($sql); $rows=mysql_fetch_array($result); if ($rows == null ) { header('location:index.php?err=4'); exit(); } else { ?> <div id="header"> <div class="wrap"><strong>Sistem Pakar untuk Mendiagnosa Kerusakan Handphone dengan Metode <em>Certainty Factor</em></strong><em></em></div></div> <div id="headerpic"> <img src="pics/nokia 6600-2.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/Nokia-6600-Reviews.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/nokia6610.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6610_pic2.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6630.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/nokia6630-2.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/Nokia_6670.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/nokia_6670_L_01.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/n6680_main1.jpg" title="Nokia 6680" class="headerpic" /> <img src="pics/nokia6680.jpg" title="Nokia 6680" class="headerpic" /> </div> <div id='menu'> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer #in case user has come for first time and cookies are not set then if (!isset($_COOKIE['username'])) { echo "<form action='check_login.php' method='post' name='formlogin'> <table width='307' height='58' border='0'> <tr> <td width='69'>Username</td> <td width='10'>:</td> <td width='153'><input type='text' name='loginusername' id='username' /></td> <td width='345'></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input type='password' name='loginpass' id='loginpass' /></td> <td><input type='submit' name='login' id='login' value='Login' /></td>
</form> <tr> <td colspan='4'>"; echo "</td> </tr> </table>"; } //if cookies are set then use them else{ echo "<table width='307' height='58' border='0'> <tr align='left'> <td ><b>Welcome " . $_COOKIE["username"] . "</b> </td> </tr></table>"; } ?> <!-- menu list --> <label for="list_menu"></label> <table width="139" border="0" align="left"> <tr align='left'> <td><?php if (isset($_COOKIE['username']))
{ echo "<form action='logout.php' method='post'> <input type='submit' value='Log Out' /></form>";
} ?></td> </tr> <tr align='left'> <td><?php if (isset($_COOKIE['type']))
{ if ($_COOKIE['type'] == 'Admin' || $_COOKIE['type'] == 'Pakar') { echo "<form action='list_hp.php' method='post'>
<input type='submit' value='List HP' /></form></td> </tr> <tr align='left'> <td><form action='list_gejala.php' method='post'> <input type='submit' value='List Gejala' /></form></td> </tr> <tr align='left'> <td>";
} if ($_COOKIE['type'] == 'Admin') { echo "<form action='list_member.php' method='post'>
<input type='submit' value='List Member' /></form>"; } } ?>
</tr> <tr align='left'> <td ><form action='about.php' method='post'> <input type='submit' value='About' /></form></td> </tr> <tr> <td></td> </tr> </table> </div> <div id="content"> <form method="post" action="result_pr.php"> <table width="580" border="1" align="center" cellpadding="3" cellspacing="1" > <tr> <td width="460" align="center" bgcolor="#33CC99"><strong>Nama Gejala</strong></td> <td width="20" align="center" bgcolor="#33CC99"><strong>Ya</strong></td> <td width="80" align="center" bgcolor="#33CC99"><strong>Tidak Tahu</strong></td> <td width="20" align="center" bgcolor="#33CC99"><strong>Tidak</strong></td> </tr> <?php $sql="SELECT * FROM $tblaturan"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ $ids_gejala[] = $rows['ID_gejala']; } $ids_gejala = array_unique($ids_gejala); sort($ids_gejala); $length_gejala = count($ids_gejala); for ($x =0; $x<$length_gejala;$x++) {
$y = $ids_gejala[$x]; $sql="SELECT * FROM $tbl2 where ID_gejala = '$y'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <tr> <td bgcolor= <?php echo $bgclr,">"; echo $rows['Nama_gejala']; ?> </td> <td align="center" bgcolor= <?php echo $bgclr,">"; ?><label> <input type="radio" name="rad[<?php echo $rows['ID_gejala']; ?>]" value="1" /> </label> </td> <td align="center" bgcolor= <?php echo $bgclr,">"; ?> <label> <input type="radio" name="rad[<?php echo $rows['ID_gejala']; ?>]" value="0" /> </label></td> <td align="center" bgcolor= <?php echo $bgclr,">"; ?> <label>
</label></td> </tr> <?php if ($bgclr == "#00FF66") {
$bgclr = "#00FFFF"; } else {
$bgclr = "#00FF66"; } } // Exit looping and close connection mysql_close(); ?> <tr> <td align="center" width="460" bgcolor= #33CC99> <?php if ($_GET['err'] == "1") { echo " <p style=color:red; > Data tidak lengkap, harap dicek kembali. </p>"; } ?> </td> <input type="hidden" name="type_hp" value="<?php echo $type_hp; ?>"/> <input type="hidden" name="length_gejala" value="<?php echo $length_gejala; ?>"/> <td align="center" width="20" bgcolor= #33CC99></td> <td align="center" width="80" bgcolor= #33CC99><input type='submit' value='Next >>'></form></td> <td align="center" width="20" bgcolor= #33CC99></td> </tr> </table> </div> <div class ="wrap1"> </div> <div id="footer"> <div class ="wrap"> <p><br />&copy; 2015 - Nico Junari</p> </div></div> <?php } ?> </body> </html> 3.
Result.php (Halaman Result)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html ns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Result</title> </head> <body> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer $bgclr = "#00FF66"; //check if field is empty,if yes,return to index if ($_GET['cf_end'] == null ) { header('location:index.php?err=4'); exit();
} $cf_enda=$_GET['cf_end']; $cf_enda= explode (" ",$cf_enda); $cf_end = $cf_enda[0]; $typeh = $cf_enda[1]; $cf_end = unserialize(base64_decode($cf_end)); ?> <div id="header"> <div class="wrap"><strong>Sistem Pakar untuk Mendiagnosa Kerusakan Handphone dengan Metode <em>Certainty Factor</em></strong><em></em></div></div> <div id="headerpic"> <img src="pics/nokia 6600-2.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/Nokia-6600-Reviews.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/nokia6610.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6610_pic2.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6630.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/nokia6630-2.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/Nokia_6670.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/nokia_6670_L_01.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/n6680_main1.jpg" title="Nokia 6680" class="headerpic" /> <img src="pics/nokia6680.jpg" title="Nokia 6680" class="headerpic" /> </div> <div id='menu'> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer #in case user has come for first time and cookies are not set then if (!isset($_COOKIE['username'])) { echo "<form action='check_login.php' method='post' name='formlogin'> <table width='307' height='58' border='0'>
<td width='69'>Username</td> <td width='10'>:</td> <td width='153'><input type='text' name='loginusername' id='username' /></td> <td width='345'></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input type='password' name='loginpass' id='loginpass' /></td> <td><input type='submit' name='login' id='login' value='Login' /></td> </tr>
</form> <tr> <td colspan='4'>"; echo "</td> </tr> </table>"; } //if cookies are set then use them else{ echo "<table width='307' height='58' border='0'> <tr align='left'> <td ><b>Welcome " . $_COOKIE["username"] . "</b> </td> </tr></table>"; } ?> <!-- menu list --> <label for="list_menu"></label> <table width="139" border="0" align="left"> <tr align='left'> <td><?php if (isset($_COOKIE['username']))
{ echo "<form action='logout.php' method='post'> <input type='submit' value='Log Out' /></form>";
} ?></td> </tr> <tr align='left'> <td><?php if (isset($_COOKIE['type']))
{ if ($_COOKIE['type'] == 'Admin' || $_COOKIE['type'] == 'Pakar') { echo "<form action='list_hp.php' method='post'>
<input type='submit' value='List HP' /></form></td> </tr> <tr align='left'> <td><form action='list_gejala.php' method='post'>
</tr> <tr align='left'> <td>";
} if ($_COOKIE['type'] == 'Admin') { echo "<form action='list_member.php' method='post'>
<input type='submit' value='List Member' /></form>"; } } ?> </td>
</tr> <tr align='left'> <td ><form action='about.php' method='post'> <input type='submit' value='About' /></form></td> </tr> <tr> <td></td> </tr> </table> </div> <div id="content"> <table width="700" border="1" align="center" cellpadding="3" cellspacing="1" > <tr> <td width="280" align="center" bgcolor="#33CC99"><strong>Nama Masalah</strong></td> <td width="20" align="center" bgcolor="#33CC99"><strong>Nilai CF</strong></td> <td width="100" align="center" bgcolor="#33CC99"><strong>Definisi CF</strong></td> <td width="300" align="center" bgcolor="#33CC99"><strong>Solusi</strong></td> </tr> <?php $tbl = masalah.$typeh; $length_cf = count($cf_end); arsort($cf_end); $varindex = array_keys($cf_end); for ($x =0; $x<$length_cf;$x++) {
$indexmasalah = $varindex[$x]; $sql="SELECT * FROM $tbl where ID_masalah = '$indexmasalah'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result) ?> <tr> <td align="center" bgcolor= <?php echo $bgclr,">"; echo $rows['Nama_masalah'];
<td align="center" bgcolor= <?php echo $bgclr,">"; if ($cf_end[$indexmasalah] == -0) echo 0; else echo $cf_end[$indexmasalah]; ?> </td> <td align="center" bgcolor= <?php echo $bgclr,">"; if ($cf_end[$indexmasalah] == 1) echo "Pasti"; else if ($cf_end[$indexmasalah] >= 0.8) echo "Hampir Pasti"; else if ($cf_end[$indexmasalah] >= 0.6) echo "Sepertinya"; else if ($cf_end[$indexmasalah] >= 0.2) echo "Mungkin"; else if ($cf_end[$indexmasalah] >= 0) echo "Mungkin ya dan mungkin saja tidak"; else if ($cf_end[$indexmasalah] >= -0.2) echo "Mungkin bukan"; else if ($cf_end[$indexmasalah] >= -0.6) echo "Sepertinya bukan"; else if ($cf_end[$indexmasalah] >= -0.8) echo "Bukan"; else if ($cf_end[$indexmasalah] == -1) echo "Pasti Bukan"; else echo "Tidak diketahui"; ?> </td> <td align="center" bgcolor= <?php echo $bgclr,">"; if ($cf_end[$indexmasalah] >= 0) echo $rows['Solusi']; ?> </td> </tr> <?php if ($bgclr == "#00FF66") {
$bgclr = "#00FFFF"; } else {
$bgclr = "#00FF66"; } } // Exit looping and close connection mysql_close(); ?> <tr> <td align="center" width="280" bgcolor= #33CC99></td> <td align="center" width="20" bgcolor= #33CC99></td> <td align="center" width="100" bgcolor= #33CC99><form method="post"
<td align="center" width="300" bgcolor= #33CC99></td> </tr> </table> </div> <div class ="wrap1"> </div> <div id="footer"> <div class ="wrap"> <p><br />&copy; 2015 - Nico Junari</p> </div></div> </body> </html> 4.
Result_pr.php (Halaman Result Proses)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer $type_hp = $_POST['type_hp']; $length_gejala = $_POST['length_gejala']; $rad = $_POST['rad']; //check if field is empty,if yes,return if ($rad == null || $length_gejala != count($rad)) { header('location:process.php?err=1&type_hp='.$type_hp); exit();
} else { $typeh = str_replace(' ','',$type_hp); $tblaturan="aturan".$typeh; $tblmasalah="masalah".$typeh; $sql="SELECT * FROM $tblaturan"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){
$x = $rows['ID_gejala']; $cf_pakar[] = $rad[$x]; $id_masalah[] = $rows['ID_masalah'];
$id_masalah =array_unique($id_masalah); sort($id_masalah); $length_masalah = count($id_masalah); for ($y =0; $y<$length_masalah;$y++) {
$z = $id_masalah[$y]; $sql="SELECT * FROM $tblaturan WHERE ID_masalah = '$z'"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){
$x = $rows['ID_rule']-1; if ($cf_end[$z] === null) { $cf_end[$z] = $cf_pakar[$x];
} else { $cf_end[$z] = min($cf_pakar[$x],$cf_end[$z]);
} } } $sql="SELECT * FROM $tblmasalah"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){
$x = $rows['ID_masalah']; $cf_end[$x] = $rows['CF_pakar'] * $cf_end[$x];
} $cf_end = base64_encode(serialize($cf_end)); $cf_end = $cf_end.' '.$typeh; header('location:result.php?cf_end='.$cf_end); exit();
} ?> </body> </html> 5.
Style.css
/*CSS RESET*/ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-size: 100%; vertical-align: baseline; } body { line-height: 1; color: black; background: white;
} ol, ul { list-style: none;
} /* tables still need 'cellspacing="0"' in the markup */ table { border-collapse: separate; border-spacing: 1;
} caption, th { text-align: left; font-weight: normal;
} blockquote:before, blockquote:after, q:before, q:after { content: ""; } blockquote, q { quotes: "" "";
} strong { font-weight:bold;color:#000;
} em { font-style:oblique;
} p { margin:15px 0;
} .aligncenter, div.aligncenter { display: block; margin-left: auto; margin-right: auto;
} .alignleft { float: left; } float: right; } h1 {font-size:180%;} h2 {font-size:150%;} h3 {font-size:125%;} h4 {font-size:100%;} h5 {font-size:90%;} h6 {font-size:80%;} a:link {color:#0289ce;} a:hover {color:#f64274;} /*End RESET - Begin Full Width CSS*/ body { text-align: center;
} img { margin: 2px; padding: 5px;
} table { margin: 5px; padding: 5px; border-collapse:separate; border-spacing: 2px;
} #content td { padding: 5px; } .wrap { padding:25px;
} #header, #headerpic, #footer, #content { margin:0 auto; padding:15px 0; min-width:100%;
} #menu { float:left; width:400px; height::300px;
} #content { text-align: left;
} #header { font-size:36px;
} .contentbig { font-size:20px;
} .headerpic { min-width:80px; min-height:100px; max-height:100px; max-width:80px;
} .wrap1 { padding:50px;
} #footer {
/* position:fixed; bottom:0; */ text-align:center;
} 6.
About.php (Halaman About)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>About</title> </head> <body> <div id="header">
<div class="wrap"><strong>Sistem Pakar untuk Mendiagnosa Kerusakan Handphone dengan Metode <em>Certainty Factor</em></strong><em></em></div></div> <div id="headerpic"> <img src="pics/nokia 6600-2.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/Nokia-6600-Reviews.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/nokia6610.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6610_pic2.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6630.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/nokia6630-2.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/Nokia_6670.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/nokia_6670_L_01.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/n6680_main1.jpg" title="Nokia 6680" class="headerpic" /> <img src="pics/nokia6680.jpg" title="Nokia 6680" class="headerpic" /> </div> <div id='menu'> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer #in case user has come for first time and cookies are not set then if (!isset($_COOKIE['username'])) { echo "<form action='check_login.php' method='post' name='formlogin'> <table width='307' height='58' border='0'> <tr> <td width='69'>Username</td> <td width='10'>:</td> <td width='153'><input type='text' name='loginusername' id='username' /></td> <td width='345'></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input type='password' name='loginpass' id='loginpass' /></td> <td><input type='submit' name='login' id='login' value='Login' /></td> </tr>
</form> <tr> <td colspan='4'></td> </tr> </table>"; } //if cookies are set then use them else{ echo "<table width='307' height='58' border='0'> <tr>
<td align='justify'><b>Welcome " . $_COOKIE["username"] . "</b> </td> </tr></table>"; } ?> <!-- menu list --> <label for="list_menu"></label> <table width="139" border="0" align="left"> <tr align='left'> <td><?php if (isset($_COOKIE['username']))
{ echo "<form action='logout.php' method='post'> <input type='submit' value='Log Out' /></form>";
} ?></td> </tr> <tr align='left'> <td><?php if (isset($_COOKIE['type']))
{ if ($_COOKIE['type'] == 'Admin' || $_COOKIE['type'] == 'Pakar') { echo "<form action='list_hp.php' method='post'>
<input type='submit' value='List HP' /></form></td> </tr> <tr align='left'> <td><form action='list_gejala.php' method='post'> <input type='submit' value='List Gejala' /></form></td> </tr> <tr align='left'> <td>";
} if ($_COOKIE['type'] == 'Admin') { echo "<form action='list_member.php' method='post'>
<input type='submit' value='List Member' /></form>"; } } ?> </td>
</tr> <tr align='left'> <td><form action='index.php' method='post'> <input type='submit' value='Index' /></form></td> </tr> <tr> <td>&nbsp;</td> </tr> </table>
<div id="content"> <p>Sistem ini dibuat oleh :</p> <p class="contentbig"> <strong>Nico Junari <br /> 071401058 <br /> Ilmu Komputer S1 </strong></p> </div> <div class ="wrap1"> </div> <div id="footer"> <div class ="wrap"> <p>&copy; 2015 - Nico Junari</p> </div></div> </body> </html> 7.
Add_aturan.php (Halaman Add Aturan)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Add Aturan</title> </head> <body> <?php #in case user has come for first time and cookies are not set then if (!isset($_COOKIE['username'])) { header('location:index.php?err=3'); exit();
} ?> <div id="header"> <div class="wrap"><strong>Sistem Pakar untuk Mendiagnosa Kerusakan Handphone dengan Metode <em>Certainty Factor</em></strong><em></em></div></div> <div id="headerpic"> <img src="pics/nokia 6600-2.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/Nokia-6600-Reviews.jpg" title="Nokia 6600" class="headerpic" /> <img src="pics/nokia6610.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6610_pic2.jpg" title="Nokia 6610" class="headerpic" /> <img src="pics/nokia6630.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/nokia6630-2.jpg" title="Nokia 6630" class="headerpic" /> <img src="pics/Nokia_6670.jpg" title="Nokia 6670" class="headerpic" /> <img src="pics/nokia_6670_L_01.jpg" title="Nokia 6670" class="headerpic" />
<img src="pics/nokia6680.jpg" title="Nokia 6680" class="headerpic" /> </div> <div id='menu'> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer //check if field is empty,if yes,return if ($_POST['type_hp'] == null) { header('location:list_aturan.php?notice=4'); exit();
} $typehp = $_POST['type_hp']; $type_hp = stripslashes($typehp); $typeh= str_replace(' ','',$type_hp); $tbl_name="gejala"; $tbl_name1="masalah".$typeh; //use cookies echo "<table width='307' height='58' border='0'> <tr> <td align='justify'><b>Welcome " . $_COOKIE["username"] . "</b> </td> </tr></table>"; ?> <!-- menu list --> <label for="list_menu"></label> <table width="139" border="0" align="left"> <tr align='left'> <td><?php if (isset($_COOKIE['username']))
{ echo "<form action='logout.php' method='post'> <input type='submit' value='Log Out' /></form>"; } ?></td> </tr> <tr align='left'> <td><?php if (isset($_COOKIE['type']))
{ if ($_COOKIE['type'] == 'Admin' || $_COOKIE['type'] == 'Pakar') { echo "<form action='list_hp.php' method='post'>
<input type='submit' value='List HP' /></form></td> </tr> <tr align='left'> <td><form action='index.php' method='post'> <input type='submit' value='Index' /></form></td> </tr>
<td>"; } if ($_COOKIE['type'] == 'Admin')
{ echo "<form action='list_member.php' method='post'> <input type='submit' value='List Member' /></form>";
} } ?> </td>
</tr> <tr align='left'> <td><form action='about.php' method='post'> <input type='submit' value='About' /></form></td> </tr> </table> </div> <div id="content"> <form method="post" action="add_aturan_pr.php"> <table width="349" height="151" border="0"> <tr> <td width="89">No Aturan</td> <td width="9">:</td> <td width="237"><input name="newidrule" type="text" size="30"></textarea></td> </tr> <tr> <td width="89">Nama Masalah</td> <td width="9">:</td> <td width="237"><select name="select_masalah" > <?php $sql="SELECT * FROM $tbl_name1"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){
?> <option value="<?php echo $rows['ID_masalah'];?>"> <?php echo $rows['Nama_masalah']; ?></option>
<?php } ?></select> </td> </tr> <tr> <td width="89">Nama Gejala</td> <td width="9">:</td> <td width="237"><select name="select_gejala" > <?php $sql="SELECT * FROM $tbl_name"; while($rows=mysql_fetch_array($result)){ ?>
<option value="<?php echo $rows['ID_gejala'];?>"> <?php echo $rows['Nama_gejala']; ?></option>
<?php } ?></select> </td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td><input type="hidden" name="type_hp" value="<?php echo $type_hp; ?>"/> <td><input type='submit' value='Add' /></td> </tr> </table> </form> </div> <div class ="wrap1"> </div> <div id="footer"> <div class ="wrap"> <p>&copy; 2015 - Nico Junari</p> </div></div> </body> </html> 8.
Add_aturan_pr.php (Halaman Add Aturan Proses)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p> <?php ob_start();//Hook output buffer include('config.php'); ob_end_clean();//Clear output buffer //check if field is empty,if yes,return if ($_POST['newidrule'] == null || $_POST['select_masalah'] == null || $_POST['select_gejala'] == null || $_POST['type_hp'] == null) { header('location:list_hp.php?notice=7'); exit();
$typehp = $_POST['type_hp']; $newidrule=$_POST['newidrule']; $select_masalah=$_POST['select_masalah']; $select_gejala=$_POST['select_gejala']; // To protect against MySQL injection $type_hp = stripslashes($typehp); $typehp= str_replace(' ','',$type_hp); $type_hp = str_replace(' ','+',$type_hp); $tbl_name = 'aturan'.$typehp; $newidrule = stripslashes($newidrule); $newidrule = mysql_real_escape_string($newidrule); //check if input is numbers if ( !is_numeric($newidrule)) { header('location:list_aturan.php?notice=4&type_hp='.$type_hp); exit();
} //check if ID number is used $sql="SELECT * FROM $tbl_name where ID_rule = $newidrule"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); if ($rows == null ) { $sql="insert into $tbl_name(ID_rule,ID_masalah,ID_gejala) values('$newidrule','$select_masalah','$select_gejala')"; mysql_query($sql); header('location:list_aturan.php?notice=2&type_hp='.$type_hp); } else { header('location:list_aturan.php?notice=4&type_hp='.$type_hp); } ?> </body> </html> 9.
Add_gejala.php (Halaman Add Gejala)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html ns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Add Gejala</title> </head> <body> <?php if (!isset($_COOKIE['username'])) { header('location:index.php?err=3'); exit();