Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[php] metode pencarian
#1
Yok membua web sendiri, ne lanjutan dr tred bg complan ttg add, update, delete d php,

Kali ini untk melakn pencrian dr data yg udah tersmpn d db

PHP Code:
<form action="" method="post" name="form"> <input type="text" name="text"/> <input type="submit" name="cari"/> </form> <? include 'db.php'; if(isset($_POST['cari'])){ $cari = trim($_POST['text']); $cari = htmlentities(strip_tags($cari), ENT_QUOTES); if (empty($cari)){ echo "Anda Belum mengetik yang akan di cari<br /> <a href=javascript:history.go(-1)><b>Ulangi Lagi</b>"; } else { echo 'melakukan pencarian untuk : '.$cari.'<br/> '; $sql = mysql_query("SELECT * FROM artikel WHERE judul LIKE '%$cari%' OR artikel LIKE '%$cari%' ORDER BY id DESC"); $jumlah = mysql_num_rows($sql); if ($jumlah > 0){ echo '<p> Ada '.$jumlah.' data yang sesuai</p>'; while ($hasil=mysql_fetch_array($sql)){ echo '<a href=artikel.php?id='.$hasil['id'].'>'.$hasil['judul'].'</a><br/>'; } } else { echo "Tidak di temukan"; } } } ?>

Untk mencgh xss
$cari = htmlentities(strip_tags($cari), ENT_QUOTES);

Monggo d kembangkn
[Image: logo.png]
Reply


Messages In This Thread
[php] metode pencarian - by hogyz - 08-27-2012, 04:24 AM
RE: [php] metode pencarian - by nesta - 08-27-2012, 04:29 AM
RE: [php] metode pencarian - by hogyz - 08-27-2012, 04:40 AM
RE: [php] metode pencarian - by UHD - 08-27-2012, 04:30 AM
RE: [php] metode pencarian - by 777r - 08-27-2012, 06:02 AM
RE: [php] metode pencarian - by nesta - 08-27-2012, 08:05 PM
RE: [php] metode pencarian - by vie_opie - 08-30-2012, 07:53 PM
RE: [php] metode pencarian - by abay'z - 08-27-2012, 10:02 PM
RE: [php] metode pencarian - by HeriNHT - 08-28-2012, 12:54 AM
RE: [php] metode pencarian - by tolonggalo - 08-28-2012, 01:37 AM
RE: [php] metode pencarian - by nesta - 08-28-2012, 10:24 AM
RE: [php] metode pencarian - by tolonggalo - 08-30-2012, 07:32 AM
RE: [php] metode pencarian - by hogyz - 10-31-2012, 07:03 AM
RE: [php] metode pencarian - by hogyz - 08-29-2012, 02:03 AM
RE: [php] metode pencarian - by Up_ - 11-01-2012, 10:18 PM
RE: [php] metode pencarian - by hogyz - 11-02-2012, 02:22 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)