check against database?

Discussion in 'PHP' started by izlik, Jul 31, 2011.

  1. #1
    i have this html form
    <form action="insert.php" method="post">
    ko: <INPUT NAME="ko" SIZE=7 MAXLENGTH=20 onKeyPress="return numbersonly(this, event)">
    <input type="submit" />
    </form>
    HTML:
    Then i have this php code

    <?
    include "config.php";
    ?>
    
    $sql="INSERT INTO bokning (ko)
    VALUES
    ('$_POST[ko]')";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "X record added";
    
    mysql_close($con)
    ?>
    PHP:

    let's say the limit for "ko" is set to 3 in the database(Table named "admin", collumn named "komax") and someone enters 5 into the form and presses submit, before it's enterd into the database, how can i make it sum up every row for "ko" in the table, "bokning" and give an error if it exceeds the limit of "komax" ?
     
    izlik, Jul 31, 2011 IP
  2. freelanceinphp

    freelanceinphp Member

    Messages:
    134
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Sorry, Can you describe in details. I cannot understand your problem.
     
    freelanceinphp, Aug 1, 2011 IP