Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6054347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:08:34+00:00 2026-05-23T08:08:34+00:00

I have a form that accepts multiple inputs and then submits it to the

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:08:34+00:00Added an answer on May 23, 2026 at 8:08 am

    According to your Question. If you want to use that validation in PHP. You can use $_SESSION variables.

    In your action file.
    Use:

    <?php
        session_start();
        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($installer == '' || $fitter == '' || $guarantee == '' || $equipment == '' || $certificate == '' || $installed == ''){
            $_SESSION['status'] = 'error';
        } 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());
            $_SESSION['status'] = 'success';
       }               
    header("location: index.php");
    ?>
    

    Now in your index.php file.
    Use at the top:

    <?php
    session_start();
    if($_SESSION['status'] == 'error') {
    $msg = "Fill all form fields";
    }
    if ($_SESSION['status'] == 'success'){
    $msg = "Record succesfully added";
    }
    ?>
    

    Now use that $msg variable where you want to print the message.
    like:

    <?php echo isset($msg) ? $msg : '' ?>
    

    Note: If you dont want to reload the page then Ajax with PHP should be used. This is just the simple way. You can Use accordingly.

    Hope It helps..cheers..!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form input field that accepts multiple tags from a user, a
I have a form that has multiple fields, and for testing purposes is there
I have a form text field that accepts a url. When the form is
I have a form field that accepts large text from users. It is basically
I have a text field that accepts user input in the form of delimeted
I have an html file that accepts user inputs then uses Javascript to calculate
I have a form that accepts image file, i want to be able to
So I have a form that accepts some input from a user that may
I have a HTML form, and I have a Controller Action that accepts the
I have a form that contains a GridView control which is databound to an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.