Duplicate data php : <p>can I check the same data in input in form PHP? this is the program code, but what happens is the same data can still be entered and there is no data checking. I've tried in to change <code>if($query &gt;0)</code> bu the data can be input and be the same.</p>

<pre><code>&lt;?php
    if(!defined('INDEX')) die("");

    include("library/config.php");

    // cek apakah tombol daftar sudah diklik atau blum?
    if(isset($_POST['simpan2'])){

        // ambil data dari formulir
      $tanggalmasuk = $_POST['tanggalmasuk'];
      $tanggalmasuk =  date('Y-m-d', strtotime($tanggalmasuk));
      $nomorttb1 = $_POST['nomorttb1'];
      $nama_supplier1 = $_POST['nama_supplier1'];
      $nama_barang1 = $_POST['nama_barang1'];
      $jumlahkirim = $_POST['jumlahkirim'];
      $nomorrefrence = $_POST['nomorrefrence'];
      $nomorsurat = $_POST['nomorsurat'];

        // buat query
      $sql="SELECT * from masuk where po_nomor= '$_POST[nomorttb1]'";
        $query = mysqli_query($con, $sql);
      if($query &gt;0){
         echo "Data Sudah Ada";
        echo "&lt;meta http-equiv='refresh' content='1; url=?hal=masuk'&gt;";
      }else{
      $sql = "INSERT INTO masuk( tanggal, po_nomor, idsupplier, idbarang, terima,refrence,surat) VALUES ('$tanggalmasuk', '$nomorttb1', '$nama_supplier1', '$nama_barang1', '$jumlahkirim', '$nomorrefrence', '$nomorsurat')";
      $query = mysqli_query($con, $sql);
    }
        // apakah query simpan berhasil?
      if($query){
        echo "Data berhasil disimpan!";
        echo "&lt;meta http-equiv='refresh' content='1; url=?hal=masuk'&gt;";
      }else{
        echo "Tidak dapat menyimpan data!&lt;br&gt;";
        echo mysqli_error();
      }


    } else {
      die("Akses dilarang...");
    }
</code></pre>

<p>what I can do to my code and what I can change</p>
