edit hapus replace data dengan PHP

<html>
<head>
<title>Mencari kata dalam Kata</title>
</head>

<body>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<div class="kotak-rounded-corner">
<table align="center" border="2">
<a href="https://ridosandiatmanto.wordpress.com">
<h2 align="center">
Mencari kata dalam kata</h2></a>
<tr><td><b>Masukkan kata kunci<b></td> <td>:</td></td>
<td><input type="text" name="kata_kunci"></td>
<tr><td><b>Masukkan kata yang Rubah<b></td> <td>:</td></td>
<td><input type="text" name="dirubah"></td>
<tr>
<tr><td><b>Masukkan kata yang Hapus<b></td> <td>:</td></td>
<td><input type="text" name="dicari"></td>
<tr>
<tr><td></td><td></td><td align="center">
<input name="reset" type="reset" value="Ulangi">
<input name="submit" type="submit" value="Cari">
</td></tr>

<?php
$jumlah=0;
$kata_kunci=$_POST['kata_kunci'];
$dicari=$_POST['dicari'];
$dirubah=$_POST['dirubah'];
echo "<tr  align=\"center\" valign=\"middle\"><td><b>Teks</b></td> <td>:</td></td><td><b>".$kata_kunci."</b></td></tr>";

$n_kata=strlen($kata_kunci);
$n_cari=strlen($dicari);
$ngarep=0;
$akhir=$kata_kunci;
for ($i=0;$i<$n_kata;$i++){
		$a[$i]=substr($akhir,$i,$n_cari);
$ngarep=$ngarep+1;
			if($a[$i]==$dicari){
				$awal=substr($akhir,0,$ngarep-1);
				$akhir=substr($akhir,$i+$n_cari,$n_kata);

$akhir= $awal.$akhir;
$n_kata=strlen($akhir);

}
}

$n_kata=strlen($kata_kunci);
$n_cari=strlen($dicari);
$ngarep=0;
$akhir1=$kata_kunci;
for ($i=0;$i<$n_kata;$i++){
		$a[$i]=substr($akhir1,$i,$n_cari);
$ngarep=$ngarep+1;
			if($a[$i]==$dicari){
				$awal1=substr($akhir1,0,$ngarep-1);
				$akhir1=substr($akhir1,$i+$n_cari,$n_kata);

$akhir1= $awal1.$dirubah.$akhir1;
$n_kata=strlen($akhir1);

}
}

?>
<tr  align="center" valign="middle"><td><b>Kata yang dihapus </b></td> <td>:</td><td><b><?php echo $dicari; ?></b></td></tr>
<tr  align="center" valign="middle"><td><b>Kata yang dihapus </b></td> <td>:</td><td><b><?php echo $dirubah; ?></b></td></tr>
<tr  align="center" valign="middle"><td><b>Hasil Rubah data </b></td> <td>:</td><td><b><?php
echo $akhir1;?></b></td></tr>
<tr  align="center" valign="middle"><td><b>Hasil Hapus data </b></td> <td>:</td><td><b><?php
echo $akhir;?></b></td></tr>
</table>
</div>
</form>
</body>
</html>

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: