jeudi 17 décembre 2015

How to split if else error condition

I have a validation with some if/else statements.

<?php
if (isset($_POST["join"])) { 

  if ($userpoint < $lessonpoint) { //pt
    echo "you need more points";
  } //pt

  else { //has enough point


      if ($row['num'] > 0) { //check if user took this lesson
        echo "you took this lesson before.";
      } //check if user took this lesson ends


    else { //then let him apply to database

            //define post:
            $postvalue = (int)$_POST["postvalue"];

            //and check
            if($postvalue == '' || $postvalue <= 0 || $postvalue > $minimumpostvalue || $postvalue == is_int($postvalue)) { //check post
            echo "Error."; 

            } //checkpost ends.


      else { //insert

      $sql = "INSERT into etc... VALUES (?, ?, ?)";

            if($sql){ //to another database

                $artibir = "UPDATE etc.";

                echo "Done.";

            } // to another database
      }//insert
    } //let him apply
  } //has enough point
} //if post isset join
?>

This works very well.

But I want to echo out another error message for this condition: $postvalue > $minimumpostvalue

While trying it I get lost inside the if/else statements. Wherever I put new statement I'm having an error.

All variables are defined.

Where and how can I place $postvalue > $minimumpostvalue to echo a different error message?

Thanks a lot..

Aucun commentaire:

Enregistrer un commentaire