Untuk kali ini sahabat bahasaaplikasi.com akan menjelaskan proses Fuzzy Login menggunakan bahasa Pemograman PHP dan MySql.

Memang sangatlah mudah untuk mengimplementasikan Fuzzy Logic Model Mamdani kedalam Bahasa Pemograman PHP dan MySql jika kita sudah menguasai perhitungan metode Fuzzy Logic, jika aplikasi yang akan kita buat bersifat statis, dimana kriteria tidak bisa ditambahkan, tentu sangatlah mudah. namun bagaimana jika kita buat dinamis, apakah akan mudah?

Berikut akan saya jelaskan cara implementasinya.
Sampai saat ini tentunya sobat sudah mengerti tentang cara pembuatan Database MySql dan cara membuat form dengan bahasa pemograman PHP. jika belum silahkan sobat baca :
Langkah-Langkah Membuat Database MySql di Xampp
Langkah-Langkah Membuat Form Simpan, Edit dan Hapus dengan PHP dan MySql
Cara Koneksi Database MySql dengan PHP
Cara Membuat Aplikasi PHP include Form dalam Form Utama

Langkah-Langkah Implementasi Fuzzy Logic Model Mamdani menggunakan PHP dan MySql

Buat Database beserta dengan tabel-tabelnya seperti terlihat pada gambar dibawah ini

atau silahkan copy Script dibawah ini.
-- phpMyAdmin SQL Dump -- version 3.1.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Waktu pembuatan: 04. Nopember 2018 jam 03:39 -- Versi Server: 5.1.30 -- Versi PHP: 5.2.8 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `pakarkesuburantanah` -- -- -------------------------------------------------------- -- -- Struktur dari tabel `data_pakar` -- CREATE TABLE IF NOT EXISTS `data_pakar` ( `username` varchar(10) NOT NULL, `password` varchar(50) NOT NULL, `pertanyaan` varchar(50) NOT NULL, `jawaban` varchar(50) NOT NULL, PRIMARY KEY (`username`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Struktur dari tabel `data_user` -- CREATE TABLE IF NOT EXISTS `data_user` ( `username` varchar(20) NOT NULL, `password` varchar(200) NOT NULL, `nama_user` varchar(30) NOT NULL, `usia` char(2) NOT NULL, `jenis_kelamin` enum('L','P') NOT NULL, `alamat` varchar(50) NOT NULL, `pertanyaan` varchar(100) NOT NULL, `jawaban` varchar(200) NOT NULL, PRIMARY KEY (`username`,`password`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Struktur dari tabel `jenistanaman` -- CREATE TABLE IF NOT EXISTS `jenistanaman` ( `id` int(11) NOT NULL AUTO_INCREMENT, `jenis_tanah` text NOT NULL, `tanaman` varchar(50) NOT NULL, `a` char(3) NOT NULL, `b` char(3) NOT NULL, `ket` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ; -- -- Struktur dari tabel `riwayat` -- CREATE TABLE IF NOT EXISTS `riwayat` ( `id` int(11) NOT NULL AUTO_INCREMENT, `iduser` varchar(20) NOT NULL, `kode` char(4) NOT NULL, `tanggal` datetime NOT NULL, `idjt` int(11) NOT NULL, `bobot` char(5) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Struktur dari tabel `rule` -- CREATE TABLE IF NOT EXISTS `rule` ( `id` int(11) NOT NULL AUTO_INCREMENT, `kode` char(3) NOT NULL, `idvar` int(11) NOT NULL, `aturan` text NOT NULL, `maka` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ; -- -- Struktur dari tabel `tmp_analisa` -- CREATE TABLE IF NOT EXISTS `tmp_analisa` ( `username` varchar(10) NOT NULL, `idvar` varchar(5) NOT NULL, `nilai` varchar(5) NOT NULL, `atr` varchar(30) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `variabel` ( `idvar` int(11) NOT NULL AUTO_INCREMENT, `variabel` varchar(50) NOT NULL, `him1` varchar(30) NOT NULL, `him2` varchar(30) NOT NULL, `him3` varchar(30) NOT NULL, `r1` char(4) NOT NULL, `r2` char(4) NOT NULL, `r3` char(4) NOT NULL, `s1` char(4) NOT NULL, `s2` char(4) NOT NULL, `s3` char(4) NOT NULL, PRIMARY KEY (`idvar`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;

Buat Form dengan extensi (.php) dan simpan dalam folder "C://xampp/htdocs/Nama Aplikasi/" form yang dibuat berupa:
1. Form Login
"; exit(); } else { //Login failed echo ""; exit(); } } }else { die("Query failed"); } $act=$_GET['act']; if ($act=="logout"){ session_start(); unset($_SESSION['SESS_USERNAME']); ""; } ?>

2. Form  User
<link href="style.css" rel="stylesheet" type="text/css">
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {
font-size: xx-small;
font-style: italic;
color: #333333;
}
-->
</style>
<div class="text_area" align="justify">
<br/>
<div class="title">Form Registrasi</div>
<form action="proses_registrasi.php" method="post">
<table align="left" cellpadding="5">
<tr>
<td colspan="3"><hr color="#AAAAAA"></td>

</tr>
<tr>
<td colspan="3"><div class="subtitle">Biodata Diri </div></td>

</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><span id="sprytextfield4">
<input name="nama_user" type="text" size="30" maxlength="30">
<span class="textfieldRequiredMsg"><img src="images/cancel_f2.png"width="10" height="10"> Nama Anak harus diisi.</span>
<span class="textfieldMinCharsMsg"><img src="images/cancel_f2.png"width="10" height="10"> Panjang minimal 2 karakter.</span>
<span class="textfieldInvalidFormatMsg"><img src="images/cancel_f2.png"width="10" height="10"> Format penulisan salah.</span></span></td>
</tr>
<tr>
<td valign="top">Umur</td>
<td valign="top">:</td>
<td valign="bottom">
<span id="validsel">
<select name="usia">
<option value="">Pilih Usia</option>
<option value="1">1 Tahun</option>
<option value="2">2 Tahun</option>
<option value="3">3 Tahun</option>
<option value="4">4 Tahun</option>
<option value="5">5 Tahun</option>
<option value="6">6 Tahun</option>
<option value="7">7 Tahun</option>
<option value="8">8 Tahun</option>
<option value="9">9 Tahun</option>
<option value="10">10 Tahun</option>
<option value="11">11 Tahun</option>
<option value="12">12 Tahun</option></select>
<span class="selectRequiredMsg"><img src="images/cancel_f2.png"width="10" height="10"> Usia Anak harus dipilih.</span></span>
</td>
</tr>
<tr>
<td>Jenis Kelamin</td>
<td>:</td>
<td><input name="jenis_kelamin" type="radio" value="L" checked="checked" /> Laki-laki
<input name="jk" type="radio" value="P" /> Perempuan</td>
</tr>
<tr>
<td>Alamat</td>
<td>:</td>
<td><span id="sprytextfield6">
<input name="alamat" type="text" size="50" maxlength="100" />
<span class="textfieldRequiredMsg"><img src="images/cancel_f2.png"width="10" height="10"> Alamat harus diisi.</span>
<span class="textfieldMinCharsMsg"><img src="images/cancel_f2.png"width="10" height="10"> Minimal 4 karakter.</span>
<span class="textfieldInvalidFormatMsg"><img src="images/cancel_f2.png"width="10" height="10"> Format penulisan salah.</span>
</span></td>
</tr>
<tr>
<td colspan="3"><hr color="#AAAAAA"></td>

</tr>
<tr>
<td valign="top">Username</td>
<td valign="top">:</td>
<td valign="bottom" ><span id="sprytextfield7">
<input name="username" type="text" size="30" maxlength="30"/>
<span class="textfieldRequiredMsg"><img src="images/cancel_f2.png"width="10" height="10"> Username Harus Diisi.</span>
<span class="textfieldMinCharsMsg"><img src="images/cancel_f2.png"width="10" height="10"> Panjang minimal 5 karakter.</span>
<span class="textfieldInvalidFormatMsg"><img src="images/cancel_f2.png"width="10" height="10"> Format penulisan tanpa spasi.</span>
<br>
<span class="style2">Panjang minimal 5 karakter.</span>

</td>
</tr>
<tr>
<td valign="top">Password</td>
<td valign="top">:</td>
<td valign="bottom"><span id="sprypassword">
<input name="password" type="password" id="password" size="15" maxlength="30" />
<span class="passwordRequiredMsg"><img src="images/cancel_f2.png"width="10" height="10"> Password Harus Diisi.</span>
<span class="passwordMinCharsMsg"><img src="images/cancel_f2.png"width="10" height="10"> Minimal 6 karakter.</span></span>
<br>
<span class="style2">Panjang minimal 6 karakter.</span>
</td>

</tr>
<tr>
<td>Konfirmasi Password</td>
<td>:</td>
<td><span id="spryconfirm">
<input name="password2" type="password" size="15" maxlength="30" />
<span class="confirmRequiredMsg"><img src="images/cancel_f2.png"width="10" height="10"> Konfirmasi Password Harus Diisi.</span>
<span class="confirmInvalidMsg"><img src="images/cancel_f2.png"width="10" height="10"> Password Harus Cocok.</span></span></td>
</tr>

<tr>
<td colspan="3"><hr color="#AAAAAA"></td>

</tr>
<tr>
<td colspan="3"><div class="subtitle">Jika Anda Lupa Password</div></td>
</tr>
<tr>
<td>Pilih Pertanyaan Rahasia</td>
<td>:</td>
<td><select name="pertanyaan" id="pertanyaan">
<option value="Apa Makanan Favorit Anda?">Apa Makanan Favorit Anda?</option>
<option value="Apa Buku Favorit Anda?">Apa Buku Favorit Anda?</option>
<option value="Apa Nama Sekolah Dasar Anda?">Apa Nama Sekolah Dasar Anda?</option>
<option value="Siapa Nama Sahabat Anda Waktu Masih Kecil?">Siapa Nama Sahabat Anda Waktu Masih Kecil?</option>
<option value="Siapa Nama Guru Favorit Anda?">Siapa Nama Guru Favorit Anda?</option>
<option value="Di Kota Manakah Ibu Anda Lahir?">Di Kota Manakah Ibu Anda Lahir?</option>
</select></td>
</tr>
<tr>
<td>Jawaban Anda</td>
<td>:</td>
<td><span id="sprytextfield88">
<input name="jawaban" type="text" size="30" maxlength="30">
<span class="textfieldRequiredMsg"><img src="images/cancel_f2.png"width="10" height="10"> Jawaban harus diisi.</span>
</span></td>
</tr>
<tr>
<td colspan="3"><hr color="#AAAAAA"></td>

</tr>
<tr>
<td>Masukan Angka Berikut</td>
<td>:</td>
<td><span id="sprytextfield77">
<img src="captchasecurityimages.php?width=100&height=40&character=4" /><br><br><input id="security_code" name="security_code" type="text" size="12"/>
<span class="textfieldRequiredMsg"><img src="images/cancel_f2.png"width="10" height="10"> Angka harus diisi dengan benar.</span>
<span class="textfieldMinCharsMsg"><img src="images/cancel_f2.png"width="10" height="10"> Angka harus diisi dengan benar.</span>
<span class="textfieldMaxCharsMsg"><img src="images/cancel_f2.png"width="10" height="10"> Angka harus diisi dengan benar.</span></span></td>

</tr>
<tr>
<td height="40" colspan="3" align="right" valign="bottom"><input type="submit" name="tombol" value="Daftar" /><input type="reset" name="reset" value="Hapus" />
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript">
<!--
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7","data", {minChars:5, validateOn:["blur"]});
var sprypassword = new Spry.Widget.ValidationPassword("sprypassword",{minChars:6, validateOn:["blur"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3","none", {minChars:5, validateOn:["blur"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4","nama", {minChars:2, validateOn:["blur"]});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5","integer",{minValue:1,maxValue:12, maxChars:2, validateOn:["blur"]});
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6","alamat", {minChars:4, validateOn:["blur"]});
var sprytextfield77 = new Spry.Widget.ValidationTextField("sprytextfield77","none", {minChars:4,maxChars:4, validateOn:["blur"]});
var sprytextfield88 = new Spry.Widget.ValidationTextField("sprytextfield88","nama", {validateOn:["blur"]});
var spryconfirm = new Spry.Widget.ValidationConfirm("spryconfirm", "sprypassword",{validateOn:["blur"]});
var validsel = new Spry.Widget.ValidationSelect("validsel", {validateOn:["blur"]});
//-->
</script>

3. Form Jenis Tanaman
<?php
$jenis_tanah=$_POST['jenis_tanah'];
$tanaman=$_POST['tanaman'];
$ket=$_POST['ket'];
$a=$_POST['a'];
$b=$_POST['b'];
if($_POST['simpan']){
$sql=mysql_query("insert into jenistanaman (jenis_tanah,tanaman,a,b,ket)VALUES('$jenis_tanah','$tanaman','$a','$b','$ket')")or die(mysql_error());
}
elseif($_POST['edt']){
$sql=mysql_query("update jenistanaman set jenis_tanah='$jenis_tanah',tanaman='$tanaman',a='$a',b='$b',ket='$ket'where id='$_POST[id]'")or die(mysql_error());
echo"<script language='JavaScript'>alert('Data Telah diubah');document.location='index%20i.php?page=5&current5=current&act=tanaman';</script>";
}
elseif($_GET['iddel']){
$sql=mysql_query("delete from jenistanaman where id='$_GET[iddel]'")or die(mysql_error());
echo"<script language='JavaScript'>alert('Data Telah hapus');document.location='index%20i.php?page=4&current4=current&act=tanaman';</script>";
}
?>
<?php
$cek=mysql_query("select *from jenistanaman where id='$_GET[id]'")or die(mysql_error());
$h=mysql_fetch_array($cek);
?>
<style type="text/css">
<!--
.style1 { color: #0000CC;
font-weight: bold;
}
-->
</style>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="100%" border="0" align="center">
<tr>
<td colspan="2"><div class="title">Variabel Jenis Tanaman </div></td>
</tr>
<tr>
<td ><strong>Jenis Tanah </strong></td>
<td>
<input type="hidden" name="id" value="<?php echo $h['id'];?>" /><input name="jenis_tanah" type="text" id="jenis_tanah" value="<?php echo $h['jenis_tanah'];?>" size="50" />
</strong><strong>Range </strong><strong>:</strong>
<input name="a" type="text" id="a" value="<?php echo $h['a'];?>" size="5" />
Sampai
<input name="b" type="text" id="b" value="<?php echo $h['b'];?>" size="5" /></td>
</tr>
<tr>
<td ><strong>Tanaman </strong></td><td>
<input type="hidden" name="id" value="<?php echo $h['id'];?>" /><input name="tanaman" type="text" id="tanaman" value="<?php echo $h['tanaman'];?>" size="50" />
</strong></td>
</tr>
<tr>
<td width="144"><strong>Keterangan</strong></td>
<td width="912"><label>
<textarea name="ket" id="ket" cols="45" rows="5"><?php echo $h['ket'];?></textarea>
</label></td>
</tr>
<tr>
<td height="31">&nbsp;</td>
<td height="31">&nbsp;</td>
</tr>
<tr>
<td height="31"><div align="center">
</div></td>
<td height="31">
<div align="left">
<? if ($_GET['id']){
?>
<input type="submit" class="Button" name="edt" value="Update" />
<?
}else{
?>
<input type="submit" class="Button" name="simpan" value="Simpan" />
<?
}
?>
<input type="button" class="Button" name="Submit32" value="Kembali" onclick="self.history.back()"/>
</div></td></tr>
<tr>
<td colspan="2"><div align="center"></div></td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" bordercolor="#666666" id="pag">
<tr class="<?php if($no%2==1) echo "isitabelganjil"; else echo "isitabelgenap";?>">
<td><span class="style1">No</span></td>
<td><span class="style1">Jenis Tanah</span></td>
<td><span class="style1">Tanaman</span></td>
<td ><div align="center" class="style1">Keterangan </div></td>
<td ><div align="center" class="style1">Range</div></td>
<td><span class="style1">Aksi</span></td>
</tr>
<?php $list=mysql_query("select * from jenistanaman ORDER by id ASC")or die(mysql_error());
while ($row=mysql_fetch_array($list)){
$no++;
?>
<tr class="<?php if($no%2==1) echo "isitabelganjil"; else echo "isitabelgenap";?>">
<td><?php echo $no;?></td>
<td><?php echo $row['jenis_tanah'];?></td>
<td><?php echo $row['tanaman'];?></td>
<td><div align="center"><?php echo $row['ket'];?></div></td>
<td><div align="center"><?php echo $row['a']."-". $row['b'];?></div></td>
<td><a href="index%20i.php?page=5&current5=current&act=tanamanedit&&id=<?php echo $row['id'];?>"><img src="images/edit.png" border="0" /></a> <a href="index%20i.php?page=5&current5=current&act=tanaman&&iddel=<?php echo $row['id'];?>" onclick="return confirm('Apakah anda yakin data penyakit ini akan dihapus?')"><img src="images/hapus.png" /></a></td>
</tr>
<?
}
?>
</table>
<p>&nbsp;</p>
</form>

4. Form Kriteria
<?php
$variabel=$_POST['variabel'];
$him1=$_POST['him1'];
$him2=$_POST['him2'];
$him3=$_POST['him3'];
$r1=$_POST['r1'];
$r2=$_POST['r2'];
$r3=$_POST['r3'];
$s1=$_POST['s1'];
$s2=$_POST['s2'];
$s3=$_POST['s3'];
if($_POST['simpan']){
$sql=mysql_query("insert into variabel (variabel,him1,him2,him3,r1,r2,r3,s1,s2,s3)VALUES('$variabel','$him1','$him2','$him3','$r1','$r2','$r3','$s1','$s2','$s3')")or die(mysql_error());
}
elseif($_POST['edt']){
$sql=mysql_query("update variabel set variabel='$variabel',him1='$him1',him2='$him2',him3='$him3',r1='$r1',r2='$r2',r3='$r3',s1='$s1',s2='$s2',s3='$s3' where idvar='$_POST[idvar]'")or die(mysql_error());
echo"<script language='JavaScript'>alert('Data Telah diubah');document.location='index%20i.php?page=4&current4=current&act=variabel';</script>";
}
elseif($_GET['iddel']){
$sql=mysql_query("delete from variabel where idvar='$_GET[iddel]'")or die(mysql_error());
echo"<script language='JavaScript'>alert('Data Telah hapus');document.location='index%20i.php?page=4&current4=current&act=variabel';</script>";
}
?>
<?php
$cek=mysql_query("select *from variabel where idvar='$_GET[id]'")or die(mysql_error());
$h=mysql_fetch_array($cek);
?>
<style type="text/css">
<!--
.style1 {
color: #0000CC;
font-weight: bold;
}
-->
</style>
<div class="title"> Variabel Kriteria </div>
<form action="" method="post" target="_self">
<table width="100%" border="0" align="center">
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td width="181"><strong>Variabel</strong></td>
<td colspan="2"><strong>:</strong> <input type="hidden" name="idvar" value="<?php echo $h['idvar'];?>" /><input name="variabel" type="text" id="variabel" size="40" value="<?php echo $h['variabel'];?>" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="59">&nbsp;</td>
<td width="851">&nbsp;</td>
</tr>
<tr>
<td colspan="3"><strong>Himpunan Fuzzy 1
<input name="him1" type="text" id="him1" value="<?php echo $h['him1'];?>" />
Range </strong><strong>:</strong>
<input name="r1" type="text" id="r1" size="5" value="<?php echo $h['r1'];?>" />
Sampai
<input name="s1" type="text" id="s1" size="5" value="<?php echo $h['s1'];?>"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3"><strong>Himpunan Fuzzy 2
<input name="him2" type="text" id="him2" value="<?php echo $h['him2'];?>" />
</strong><strong>Range :</strong>
<input name="r2" type="text" id="r2"size="5" value="<?php echo $h['r2'];?>" />
Sampai
<input name="s2" type="text" id="s2" size="5" value="<?php echo $h['s2'];?>"/></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3"><strong>Himpunan Fuzzy 3
<input name="him3" type="text" id="him3" value="<?php echo $h['him3'];?>" />
Range </strong><strong>:</strong>
<input name="r3" type="text" id="r3" size="5" value="<?php echo $h['r3'];?>" />
Sampai
<input name="s3" type="text" id="s3" size="5" value="<?php echo $h['s3'];?>" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">
<? if ($_GET['id']){
?>
<input type="submit" class="Button" name="edt" value="Update" />
<?
}else{
?>
<input type="submit" class="Button" name="simpan" value="Simpan" />
<?
}
?>
<input type="button" class="Button" name="Submit32" value="Kembali" onclick="self.history.back()"/></td>
</tr>
<tr>
<td colspan="3"><div align="center"></div></td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" bordercolor="#666666" id="pag">
<tr class="<?php if($no%2==1) echo "isitabelganjil"; else echo "isitabelgenap";?>">
<td><span class="style1">No</span></td>
<td><span class="style1">Variabel</span></td>
<td colspan="3"><div align="center" class="style1">Himpunan Fuzzy </div></td>
<td><span class="style1">Aksi</span></td>
</tr>
<?php $list=mysql_query("select * from variabel ORDER by idvar ASC")or die(mysql_error());
while ($row=mysql_fetch_array($list)){
$no++;
?>
<tr class="<?php if($no%2==1) echo "isitabelganjil"; else echo "isitabelgenap";?>">
<td><?php echo $no;?></td>
<td><?php echo $row['variabel'];?></td>
<td><div align="center"><?php echo $row['him1'];?></div>
<div align="center"><?php echo $row['r1']."-". $row['s1'];?></div></td>
<td><div align="center"><?php echo $row['him2'];?></div>
<div align="center"><?php echo $row['r2']."-". $row['s2'];?></div></td>
<td><div align="center"><?php echo $row['him3'];?></div>
<div align="center"><?php echo $row['r3']."-". $row['s3'];?></div></td>
<td><a href="index i.php?page=4&current4=current&act=variabel&&id=<?php echo $row['idvar'];?>"><img src="images/edit.png" border="0" /></a> <a href="index i.php?page=4&current4=current&act=variabel&&iddel=<?php echo $row['idvar'];?>" onclick="return confirm('Apakah anda yakin data penyakit ini akan dihapus?')"><img src="images/hapus.png" /></a></td>
</tr>
<?
}
?>
</table>
<p>&nbsp;</p>
</form>

5. Form Basis Aturan
<style type="text/css">
<!--
.style5 {color: #000000}
-->
</style>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="100%" border="0" align="left">
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="122"><strong>Aturan (Rule) </strong></td>
<td width="528"><strong><span class="style5">
<input name="TxtKode" type="text" maxlength="4" size="6" value="<? echo kdauto("rule","R"); ?>" disabled="disabled" />
<input name="TxtKodeH" type="hidden" value="<? echo kdauto("rule","R"); ?>" />
</span></strong></td>
</tr>

<tr>
<td><strong>Jika</strong></td>
<td>&nbsp;</td>
</tr>
<tr><td colspan="3">
<table width="100%" border="0" align="left" cellpadding="2" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#000000">
<?php $ambil=mysql_query("select *from variabel order by idvar ASC")or die(mysql_error());
while($tampil=mysql_fetch_array($ambil)){
$him=array($tampil['him1'],$tampil['him2'],$tampil['him3']);
?>
<tr>
<td width="25%" bgcolor="#FFFFFF" ><input type="hidden" name="idvar[]" value="<?php echo $tampil['idvar'];?>" /><?php echo $tampil['variabel'];?></td>
<td width="75%" bgcolor="#FFFFFF" >
<select name="atr[]">
<option value="<?php echo $him[0];?>"><?php echo $him[0];?></option>
<option value="<?php echo $him[1];?>"><?php echo $him[1];?></option>
<option value="<?php echo $him[2];?>"><?php echo $him[2];?></option>
</select></td>
</tr>
<?
}
?>
</table></td></tr>

<tr>
<td><strong>Maka Disebut Tanah </strong></td>
<td><select name="tanaman" id="tanaman">
<option value="#">-- Pilih Output --</option>
<? $list1=mysql_query("select *from jenistanaman ORDER BY id ASC")or die(mysql_error());
while($tampil1=mysql_fetch_array($list1)){
?>
<option value="<?php echo $tampil1['id'];?>"><?php echo $tampil1['jenis_tanah'];?></option>
<?
}
?> </select> </td>
</tr>

<tr>
<td colspan="3"><div align="center">
<input type="submit" class="Button" name="simpan" value="Simpan" />
<input type="button" class="Button" name="Submit32" value="Kembali" onClick="self.history.back()"/>
</div></td>
</tr>
</table>
</form>
<?php
$kode=$_REQUEST['TxtKodeH'];
$atr=$_REQUEST['atr'];
$idvar=$_REQUEST['idvar'];
$tnm=$_REQUEST['tanaman'];
if ($_POST['simpan']){
$jum= count($atr) and count($idvar);
for ($i=0; $i<=$jum;$i++){
$eskiel=mysql_query("insert into rule(kode,idvar,aturan,maka)values('$kode','$idvar[$i]','$atr[$i]','$tnm')")or die(mysql_error());
echo "<meta http-equiv=\"refresh\" content=\"0; url=index i.php?page=6&current6=current&act=rule&pesan=Simpan Sukses\">";
}
}
?>

6. Form Konsultasi
<style type="text/css">
<!--
.style1 {color: #000099}
.style4 {font-size: 12px; font-family: Courier; }
.style5 {font-family: Arial}
.style6 {color: #990000}
-->
</style>
<form action="" method="post" target="_self">
<table width="100%" border="0" cellpadding="2" cellspacing="1">
<tr>
<td width="4%">&nbsp;</td>
<td width="9%">&nbsp;</td>
<td width="87%">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><span class="style1">No</span></td>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC"><span class="style1">Kriteria/ Variabel </span></td>
</tr>
<?php $sql=mysql_query("select *from variabel order by idvar ASC")or die(mysql_error());
while($h=mysql_fetch_array($sql)){
$no++;
?>
<tr>
<td valign="middle"><?php echo $no;?></td>
<td valign="bottom"><span class="style5">Nilai</span></td>
<td valign="middle"><div><span class="style6"><?php echo $h['variabel'];?></span></div>
<span class="style6">
<input name="idvar[]" type="hidden" id="idvar[]" size="15" value="<?php echo $h['idvar'];?>">
<input name="nilai[]" type="text" size="15" maxlength="3" required="required">
</span></td>
</tr>
<tr>
<td valign="middle">&nbsp;</td>
<td valign="middle"><span class="style5">Range</span></td>
<td valign="middle"><div><span class="style4"><?php echo $h['him1'].":". $h['r1']."-".$h['s1'];?></span></div>
<div class="style4"><?php echo $h['him2'].":". $h['r2']."-".$h['s2'];?></div>
<div class="style4"><?php echo $h['him3'].":". $h['r3']."-".$h['s3'];?></div></td>
</tr>
<tr><td colspan="3" style="border-bottom:dotted; border-bottom-color:#0000CC">
</td></tr>
<?
}
?>
<tr>
<td width="4%">&nbsp;</td>
<td width="9%">&nbsp;</td>
<td width="87%"><input type="submit" name="simpan" value="Diagnosa">&nbsp;</td>
</tr>
</table>
</form>
<?php
@session_start;
$idvar=$_REQUEST['idvar'];
$nilai=$_REQUEST['nilai'];
$atr=$_REQUEST['atr'];
if(!empty($_POST['simpan'])){
$sql=mysql_query("delete from tmp_analisa")or die(mysql_error());
$jum=count($idvar) and count($nilai)and count($atr);
for ($i=0;$i< $jum; $i++){
$sql=mysql_query("insert into tmp_analisa (username,idvar,nilai,atr)values('$_SESSION[SESS_USERNAME]','$idvar[$i]','$nilai[$i]','$atr[$i]')")or die(mysql_error());
}
echo "<meta http-equiv=\"refresh\" content=\"0; url=user_index.php?page=11&act=hasil\">";
}
?>

7. Form Hasil Diagnosa
<style type="text/css">
<!--
body,td,th {
font-family: Times New Roman;
font-size: 14px;
color: #000000;
}
-->
</style>
<div align="justify">
<table width="100%" border="0">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<?php
@session_start();
$sql=mysql_query("select * from tmp_analisa ORDER BY idvar ASC")or die(mysql_error());
while ($row=mysql_fetch_array($sql)){
$njum[]=$row['nilai'];
$n++;
$skl=mysql_query("select * from variabel where idvar='$row[idvar]'")or die(mysql_error());
while ($bar=mysql_fetch_array($skl)){
$idvar[]=$bar['idvar'];
$variabel[]=$bar['variabel'];
$r1[]=$bar['r1'];
$r2[]=$bar['r2'];
$r3[]=$bar['r3'];
$s1[]=$bar['s1'];
$s2[]=$bar['s2'];
$s3[]=$bar['s3'];
$nilai[]=$row['nilai'];
$him1[]=$bar['him1'];
$him2[]=$bar['him2'];
$him3[]=$bar['him3'];
}
}
//echo "<meta http-equiv=\"refresh\" content=\"0; url=index i.php?page=6&current6=current&act=rule&pesan=Simpan Sukses\">";
?>
<?php $jum=count($njum);
for($i=0;$i<$jum;$i++){
?>
<tr>
<td>variabel jenistanaman </td>
<td><?php echo $variabel[$i];?></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><?php echo $nilai[$i];?>(<?php
if($nilai[$i]>=$r1[$i] and $nilai[$i]<=$s1[$i]){
$fuzzy=($nilai[$i]-$r1[$i])/($s1[$i]-$r1[$i]);
$ket=$him1[$i];
}elseif($nilai[$i]>=$r2[$i] and $nilai[$i]<=$s2[$i]){
$fuzzy=($nilai[$i]-$r2[$i])/($s2[$i]-$r2[$i]);
$ket=$him2[$i];
}elseif($nilai[$i]>=$r3[$i] and $nilai[$i]<=$s3[$i]){
$fuzzy=($nilai[$i]-$r3[$i])/($s3[$i]-$r3[$i]);
$ket=$him3[$i];
}

echo $ket;?>) => ( <?php
$hasil[]=$fuzzy;
echo $fuzzy;
$eskiel=mysql_query("update tmp_analisa set atr='$ket' where idvar='$idvar[$i]' and username='$_SESSION[SESS_USERNAME]'")or die(mysql_error());
?> )</td>
<td>&nbsp;</td>
</tr>
<?
}
?>
</table>
<?
$jhasil=count($hasil);
$defuzzyfikasi= substr(($hasil[0]+$hasil[1]+$hasil[2]+$hasil[3]+$hasil[4]+$hasil[5]+$hasil[6]+$hasil[7]+$hasil[8]+$hasil[9]+$hasil[10]+$hasil[11]+$hasil[12]+$hasil[13]+$hasil[14]+$hasil[15]+$hasil[16]+$hasil[17]+$hasil[18]+$hasil[19]+$hasil[20])/($jhasil),0,5);

?>
<?php
$sqlrul=mysql_query("select *from tmp_analisa ORDER BY idvar ASC")or die(mysql_error());
while($hrul=mysql_fetch_array($sqlrul)){
$kode=$hrul['kode'];
$atr[]=$hrul['atr'];
$idvar[]=$hrul['idvar'];
}
$k=7;
for($y=0; $y <$k;$y++){
$sqlr=mysql_query("select *from rule where idvar='$idvar[$y]' and aturan='$atr[$y]' GROUP BY kode") or die(mysql_error());
$hr=mysql_fetch_array($sqlr);
$koder=$hr['kode'];
$idpeny=$hr['maka'];
}
echo "<strong>Hasil Diagnosa: </strong><br />
Berdasarkan Hasil Diagnosa Sistem dan Berdasarkan Aturan dari Pakar yaitu: $koder ";
?>
<?php
$sql1=mysql_query("select variabel.*, rule.* from variabel,rule where variabel.idvar=rule.idvar and rule.kode='$koder'")or die(mysql_error());
while($h1=mysql_fetch_array($sql1)){

?>
<?php echo $h1['variabel'];?> <span class="style8"><?php echo $h1['aturan'];?> </span>
<?
}
echo "dengan (Bobot Defuzzyfikasi ".$defuzzyfikasi." ) ";
echo "Maka Anda Terkena jenistanaman"
?>
<?php
$sql2=mysql_query("select * from jenistanaman where id='$idpeny'")or die(mysql_error());
$h2=mysql_fetch_array($sql2);
echo "<span style='color:#FF0000; font-stretch:extra-condensed;'> $h2[jenistanaman]</span> ";
$sqlbobot=mysql_query("select sum(nilai)as bobot,count(username)as jml from tmp_analisa ")or die(mysql_error());
$hbobot=mysql_fetch_array($sqlbobot);
$hasil=($hbobot['bobot']*$hbobot['jml'])/10;
$bhsil=$hasil * 10;
$persentase= $defuzzyfikasi*100 ."%";
echo " </br> <strong>Definisi jenistanaman :</strong> $h2[definisi] <br />
<strong>Solusi yang disarankan : </strong> $h2[solusi]";
$sqlk=mysql_query("insert into riwayat set iduser='$_SESSION[SESS_USERNAME]',kode='$koder',tanggal=NOW(), idjt='$idpeny',bobot='$persentase'")or die(mysql_error());
?>
</div>
<p align="justify"><?php

echo "<meta http-equiv=\"refresh\" content=\"0; url=user_index.php?page=12&act=hasildiagnosa\">";
exit;
?></p>

Jika berhasil, maka perhitungan fuzzy locgic model mamdani adalah sebagai berikut:
Halaman Diagnosa

Halaman Hasil Diagnosa

Sekian Tutorial kali ini semoga bermanfaat.
Silahkan dishare, dan follow untuk artikel selanjutnya.

Baca juga : Contoh Perhitungan Manual Metode Fuzzy Logic Model Mamdani

Subscribe to receive free email updates:

0 Response to "Implementasi Fuzzy Logic Model Mamdani Menggunakan PHP dan MySql"

Post a Comment