I have a form that accepts multiple inputs and then submits it to the database however there is a field which holds the certificate number for a record I would like to query the database before the data is inserted to ensure that the certificate number is not already present. Can i do this when the field is entered i.e when the user tabs out of the field and then display a notification?

If so can someone post an example on how to do this.

The MySQL table is called - contract
The MySQL field is called - guarantee\_no

The Form POST's to create.php (Code Below)

```
<?php
    include "includes/connection.php";

    $installer      = $_POST['inputInstaller'];
    $fitter         = $_POST['inputFitter'];
    $guarantee      = $_POST['inputGuaratnee_no'];
    $equipment      = $_POST['inputEquipment'];
    $certificate    = $_POST['inputCertificate_no'];
    $installed      = $_POST['inputInstall_date'];

    if(!$_POST['submit']){
        echo "Please Enter Data into the Form";
        printf("<script>location.href='index.php'</script>");
    } else {
        mysql_query("INSERT INTO contract (`id`,`user_id`,`installer`,`fitter`,`guarantee_no`,`contact_id`,`equipment`,`certificate_no`,`install_date`)
                       VALUES(NULL,'1','$installer','$fitter','$guarantee',NULL,'$equipment','$certificate','$installed')") or die(mysql_error());
        echo "Guarantee Record was Added, Thank You!";
        printf("<script>location.href='index.php'</script>");
    }               
?>

```

Thanks for your help in advance