Results 1 to 4 of 4

Thread: Lookup

  1. #1
    Join Date
    May 2004
    Posts
    86

    Unanswered: Lookup

    I have a form with a bunch of fields. Now one field i would like to check against my mysql tbale to see if it esists, if it does submitt the form if it dosent display an error alert window? Now the code below dosent work for me. it seems to skip over this code. i think becuas ei dont know how to grab the vaule of the text box on my form in PHP im using $_POST


    [php]
    <?
    $conn = mysql_connect("localhost","root","");
    mysql_select_db("ehpadmin",$conn);
    $name = $_GET['Dcode'];
    $listing_query= "select DX_CODE from DXCODE where DX_CODE = '$name' ";
    $listing_result = mysql_query($listing_query) or die("Error in return query<br>".mysql_error());
    $num_rows = mysql_num_rows($listing_result);
    if ($num_rows == 0)
    {
    echo("<script language=javascript>
    <!--
    alert(\"Please enter a vaild Dx Code.\");
    document.registerForm.Dcode.focus();
    return ;
    //-->
    </script>");
    }
    ?>
    thanks

    pete

  2. #2
    Join Date
    Aug 2004
    Location
    San Antonio, TX
    Posts
    84
    You say you are using POST but your code is using GET. I suspect your problem may be there. If your form is set for POST then you need to change $_GET to $_POST.

  3. #3
    Join Date
    May 2004
    Posts
    86

    ok

    sorry about that. my form is set to post. im trying to take whats inside my text box and check the vaule and see if its in my colum in my database? if it is submit the form if its not then alert box?

    much help thanks

  4. #4
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    Do you have any idea where the problem is occurring? echo the query and numrows to make sure they are returning what you are expecting. Also, try doing a print_r($_GET) to see all of those variables as well and make sure they are correct.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •