jeudi 7 juillet 2016

Logic operation failure in php

I want to do some logic operation before updating the data in MySQL. However, I think there are some problems in my logic operation. I do not which sentence is the problem. Can anyone help?

<?php
     session_start();
     if ($_POST['meetingid'] > $_SESSION["id"]){
        echo "ERROR: Wrong Meeting_ID. Update failed.<br>";
     }
        else if(empty($_POST['date'])) {
            echo "ERROR: No empty data field is allowed. Update failed. (Date field)<br>";
        }
            else if(empty($POST['committee'])) {
                echo "ERROR: No empty data field is allowed. Update failed. (Committee field)<br>";
            }
              else if(empty($_POST['session'])) {
                  echo "ERROR: No empty data field is allowed. Update failed. (Session field)<br>";
              }
              else{
        $dbhost = 'localhost';
        $dbuser = 'root';
        $dbpass = 'admin123';

        $conn = mysql_connect($dbhost, $dbuser, $dbpass);

        if(! $conn ) {
           die('Could not connect: ' . mysql_error());
        }

        $meetingid = $_POST['meetingid'];
        $date = $_POST['date'];
        $committee = $_POST['committee'];   
        $session = $_POST['session'];       


        $sql = "UPDATE `meeting` SET `Date`='$date' ,`Committee`='$committee' ,`Session`='$session' WHERE `Meeting_ID`='$meetingid'" ;
        mysql_select_db('imo resolution v.2');
        $retval = mysql_query( $sql, $conn );

                if(! $retval ) {
                    die('Could not update data: ' . mysql_error());
                    }
                    else{
                        echo "Updated data successfully<br>";
                    }


        mysql_close($conn);
            }

?>

Aucun commentaire:

Enregistrer un commentaire