Dear Team - Hello to Everyone!!!

pleae note that i m trying jump to test.php page from index.php/html using ajax and mysql, simple if text-input not found in table so it should go to test.php else stay on index.php/html page with ajax alerts, but from index page everytime receiving NOT AVAILABLE and sometime submit button not functional, below code FYR...

//index.php
$(document).ready(function() {

                //default form not submitted
                 $("#submit").data("submitted",false);    

                //preventing enter key in input field from submitting form
                $("#welcome").on("submit", function(e){
                    if($('#submit').data("submitted")===false) {
                    e.preventDefault();
                    }
                });

                 //trigger form submission
                $("#submit").on("click",function(){
                validate();
                });
});

    //default form not submitted                
    //$("#submit            
    function validate() {

                    var num = $('#invst_num').val();
                    $.ajax({
                    type: 'POST',
                    url: 'check_test.php',
                    data: num,
                    cache: false,
                    dataType: "json",
                    success: function(data) {

                            if(data){
                                alert("NOT AVAILABLE");
                            } else {
                                $("#submit").data("submitted", true);
                                $("#welcome").submit();
                                }

                            }
}   


</script>

<form action="check_test.php" method="post" name="welcome" id="welcome" />
<table width="550" border='0' align='center' cellpadding='0' cellspacing='0'>

  <tr>

    <td align="center"><label>
      Enter Inv. # *: 
        <input name="invst_num" type="text" id="invst_num" size="40"  /> 
      <input name="submit" type='submit' id='submit' />
       
        </label></td>
  </tr>

</table> 
</form>




//check_test.php
<?php 

    include ("config/config.php");

    //get the username

    if (isset($_POST['submit'])) {
    $invst_num = $_POST['invst_num'];

    //mysql query to select field username if it's equal to the username that we check '
    $sql = mysql_query("select invst_num_ar from shareholders_ar where invst_num_ar =  '$invst_num' "); 
    if ($result = mysql_num_rows($sql)>0) {
        echo ($result);
        }
    }
    ?>

    // if not found...test.php should load
    <html>
    <form 
    ...
    Register Data

    /form>
    </html>

can anyone please assist on subject request!

Thanks & Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.