Buat form untuk cek
<h4>Tambah Data</h4> <form name="tambah" id="tambah" action="t.php" method="post"> <fieldset> <input name="is" type="text"/><br/> <textarea name="de" type="text"></textarea><br/> <input type="submit" value="Tambah" name="tambah"/> </fieldset> </form>
Buat setting koneksi PHP-Mysql
<?php session_start(); $hostname_kon = "Localhost"; $database_kon = "siswa"; $username_kon = "root"; $password_kon = ""; $kon = mysql_pconnect($hostname_kon, $username_kon, $password_kon) or die("Could not connect: " . mysql_error()); mysql_select_db($database_kon, $kon);
Buat script untuk cek
$cek=mysql_num_rows(mysql_query("SELECT istilah FROM prfx_data WHERE istilah='$istilah'")) or die (mysql_error()); if($cek){ echo"data sudah ada"; } ?>
Kode lengkap
<?php session_start(); $hostname_kon = "Localhost"; $database_kon = "siswa"; $username_kon = "root"; $password_kon = ""; $kon = mysql_pconnect($hostname_kon, $username_kon, $password_kon) or die("Could not connect: " . mysql_error()); mysql_select_db($database_kon, $kon); $cek=mysql_num_rows(mysql_query("SELECT istilah FROM prfx_data WHERE istilah='$istilah'")) or die (mysql_error()); if($cek){ echo"data sudah ada"; } ?> <h4>Tambah Data</h4> <form name="tambah" id="tambah" action="t.php" method="post"> <fieldset> <input name="is" type="text"/><br/> <textarea name="de" type="text"></textarea><br/> <input type="submit" value="Tambah" name="tambah"/> </fieldset> </form>
Post a Comment
Komentarlah yang baik.
Tujukkan Karakter Bangsa Indonesia.