0

I have this form:

    <form action="" method="post">
  <input type="checkbox" name="a" value="2" /> 
  <input type="checkbox" name="b" value="4" />
<input type="submit" name="submit" value="Submit" />
    </form>

What i need, when checkbox/es is/are selected and submit button is pressed to calculate value

  • if this value is more or equivalent - query
  • if this value is less - error message

Value is checked from column name points

Thank you.

4

1 回答 1

0
if (isset($_POST['submit'])) {
   $var_a = (isset($_POST['a'])) ? 2 : 0;
   $var_b = (isset($_POST['b'])) ? 4 : 0;

   if ( ($var_a + $var_b) >= 6 ){
      // query
   }
   else {
      // error message
   }
}
于 2012-09-03T15:28:55.733 回答