Example #1
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $ticketshowID = $_POST['showid_value'];
    }
    $conn = dbConnect();
    // start connect db
    if ($conn) {
        $insert = " INSERT INTO EMM_ZOO.TICKETSHOW_BUYING (TICKETSHOW_ID, SHOWID, ROUNDID , BUYING_DATE) VALUES (DEFAULT, '{$ticketshowID}',CURRENT TIME, CURRENT DATE);";
        echo $insert;
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            header("Refresh:0; url=ShowList.php");
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($rc);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #2
0
function editCarPlate()
{
    if (isset($_POST)) {
        $carid = $_POST['update_carid'];
        $carplate = $_POST['edit_carplate'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.SANICAR SET CARID = '{$carid}', CARPLATE = '{$carplate}' WHERE CARID = {$carid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_garbage.php#car_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Example #3
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $tickettourID = $_POST['tourid_value'];
    }
    $conn = dbConnect();
    // start connect db
    if ($conn) {
        $insert = " INSERT INTO EMM_ZOO.TICKETTOUR_TRANSACTION (TICKETTOUR_ID, TOUR_ID, DATE) VALUES (DEFAULT, '{$tickettourID}', CURRENT DATE);";
        echo $insert;
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            header("Refresh:0; url=TourTicket.php");
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($rc);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #4
0
function editEquipInfo()
{
    if (isset($_POST)) {
        $equipid = $_POST['update_equipid'];
        $equipname = $_POST['edit_equipname'];
        $equiptype = $_POST['edit_equiptype'];
        $status = $_POST['edit_status'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.SANITATION_EQUIP SET EQUIPID = '{$equipid}', EQUIPNAME = '{$equipname}' , EQUIPTYPE = '{$equiptype}', STATUS = '{$status}' WHERE EQUIPID = {$equipid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_equip.php#car_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Example #5
0
function insertSaniEmp()
{
    //print_r($_POST);
    if (isset($_POST)) {
        $empid = $_POST['empid'];
        $zoneid = $_POST['zoneid'];
        $jobid = '17';
        $firstname = $_POST['firstname'];
        $lastname = $_POST['lastname'];
        $birthdate = $_POST['birthdate'];
        $sex = $_POST['sex'];
        $nationality = $_POST['nationality'];
        $hiredate = $_POST['hiredate'];
        $address = $_POST['address'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $salary = $_POST['salary'];
        $bonus = $_POST['bonus'];
        // an array that want to insert this can be multiple array at the time.
        $data = array($empid, $zoneid, $jobid, $firstname, $lastname, $birthdate, $sex, $nationality, $hiredate, $address, $email, $phone, $salary, $bonus);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        $sql = 'INSERT INTO EMM_ZOO.EMPLOYEE (EMPID, ZONEID, JOBID, FIRSTNAME, LASTNAME, BIRTHDATE, SEX, NATIONALITY, HIREDATE, ADDRESS, EMAIL, PHONE, SALARY, BONUS) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);';
        //$sql2 = 'INSERT INTO EMM_ZOO.EMP_SANI (EMPID) VALUES (?);';
        //echo $sql;
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added to sanitation employee";
                //echo "Successfully added";
                echo "<script>";
                echo "alert('Added successfully')";
                echo "</script>";
                header('Location: addEmpHome.php');
                exit;
            } else {
                $resultMessage = "Failed to query into database";
                echo "<script>";
                echo "alert('Failed to query into database')";
                echo "</script>";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error());
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Example #6
0
function uploadBioInfo()
{
    if (!isset($_SESSION['current_user_name']) && !isset($_COOKIE[$cookie_name])) {
        header('Location: ../login.php');
        exit;
    } else {
        //print_r($_POST);
        if (isset($_POST)) {
            $AnimalID = $_POST['AnimalID'];
            $species = $_POST['species'];
            $Phylum = $_POST['Phylum'];
            $Class = $_POST['Class'];
            $Order = $_POST['Order'];
            $Family = $_POST['Family'];
            $Genus = $_POST['Genus'];
            $warmblooded = $_POST['warmblooded'];
            $Cover = $_POST['Cover'];
            $Reproduction = $_POST['Reproduction'];
            $Habitat = $_POST['Habitat'];
            $food = $_POST['food'];
            $BodyTemp = $_POST['BodyTemp'];
            $EnviTemp = $_POST['EnviTemp'];
            $LifeSpan = $_POST['LifeSpan'];
            // an array that want to insert this can be multiple array at the time.
            $data = array($AnimalID, $species, $Phylum, $Class, $Order, $Family, $Genus, $warmblooded, $Cover, $Reproduction, $Habitat, $food, $BodyTemp, $EnviTemp, $LifeSpan);
            // print var_dump to display an array of variable data with type that prepare for query.
            //echo var_dump($data) ."<br>";
        }
        require_once '/var/www/html/app/model/connect.php';
        $conn = dbConnect();
        if ($conn) {
            // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
            $sql = 'INSERT INTO EMM_ZOO.BIOINFO (SPECIESID,SPECIESNAME, PHYLUM, CLASS, ORDER, FAMILY, GENUS, WARMBLOODED, BODYCOVER, REPRODUCTION, HABITAT, COMMONFOOD, BODYTEMP, ENVITEMPRANGE, LIFESPAN) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);';
            //echo $sql;
            // prepare statement using connection and sql
            $stmt = db2_prepare($conn, $sql);
            // If statement is valid execute it to db2
            if ($stmt) {
                //echo "SQL is valid<br>";
                $result = db2_execute($stmt, $data);
                if ($result) {
                    $resultMessage = "Successfully added to Biological information";
                    echo "Successfully added";
                    header('Location: BioInfo.php');
                    exit;
                } else {
                    $resultMessage = "Failed to query into database";
                }
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error());
            }
            db2_free_stmt($stmt);
            db2_close($conn);
        } else {
            echo db2_conn_errormsg();
        }
    }
}
Example #7
0
 /**
  * This function connects to a DB2 database
  *
  * @param   string $host
  * @param   string $username
  * @param   string $password
  * @param   string $db_name
  * @return  boolean TRUE, if connected, otherwise FALSE
  * @access  public
  * @author  Thorsten Rinne <*****@*****.**>
  * @since   2005-04-16
  */
 function connect($host, $user, $passwd, $db)
 {
     $this->conn = db2_pconnect($db, $user, $passwd, $this->options);
     if (false == $this->conn) {
         PMF_Db::errorPage(db2_conn_errormsg());
         die;
     }
     return true;
 }
 /**
  * Open a connection to db
  */
 public function connect()
 {
     $conn_string = "DATABASE=" . $this->dbname . ";HOSTNAME=" . $this->host . ";PORT=" . $this->port . ";PROTOCOL=TCPIP;UID=" . $this->user . ";PWD=" . $this->pwd . ";";
     $this->conn = db2_connect($conn_string, '', '');
     if (!$this->conn) {
         trigger_error(db2_conn_errormsg(), E_USER_ERROR);
     }
     return $this->conn;
 }
Example #9
0
function insertBuilding()
{
    if ($_POST['form_token'] != $_SESSION['form_token']) {
        header('Location:index.php');
    } else {
        //print_r($_POST);
        if (isset($_POST)) {
            $emm = $_POST['BEmp'];
            $zone = $_POST['BZone'];
            $build = $_POST['Building'];
            $floor = $_POST['floor'];
            $room = $_POST['room'];
            // an array that want to insert this can be multiple array at the time.
            $data = array($build, $floor, $room);
            // print var_dump to display an array of variable data with type that prepare for query.
            //echo var_dump($data) ."<br>";
        }
        // define $conn from model
        $conn = dbConnect();
        if ($conn) {
            // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
            $sql = 'INSERT INTO EMM_ZOO.MAINTAINBUILDING (MAINTEGERAINID, BUILDINGNAME, FLOORLEVEL, ROOM) VALUES (DEFAULT,?,?,?);';
            //echo $sql;
            // prepare statement using connection and sql
            $stmt = db2_prepare($conn, $sql);
            // If statement is valid execute it to db2
            if ($stmt) {
                //echo "SQL is valid<br>";
                $result = db2_execute($stmt, $data);
                if ($result) {
                    $resultMessage = "Successfully added";
                    //echo "Successfully added";
                    echo "<script>";
                    echo "alert('Successfully')";
                    echo "</script>";
                    header('Location: index.php');
                    exit;
                } else {
                    echo "<script>";
                    echo "alert('Failed')";
                    echo "</script>";
                    $resultMessage = "Failed to query into database";
                }
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error());
            }
            db2_free_stmt($stmt);
            db2_close($conn);
        } else {
            echo db2_conn_errormsg();
        }
    }
}
Example #10
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST['id_value'])) {
        $transID = $_POST['id_value'];
    }
    $conn = dbConnect();
    // start connect db
    if ($conn) {
        $update = "UPDATE EMM_ZOO.TICKETTRANS_TRANSACTION SET TICKETTRANS_TIMEIN = CURRENT TIME WHERE TICKETTRANS_ID = " . $transID . ";";
        //echo $update;
        $rc = db2_exec($conn, $update);
        if ($rc) {
            //header("Refresh:0; url=TranspotationIN.php");
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($rc);
        $sql = "SELECT * FROM EMM_ZOO.TICKETTRANS_TRANSACTION JOIN EMM_ZOO.TICKETTRANS_TYPE ON VEHICLETRANS_ID = TRANSTYPE_ID WHERE TICKETTRANS_ID = " . $transID . ";";
        $stmt = db2_exec($conn, $sql);
        while ($row = db2_fetch_assoc($stmt)) {
            $tran_price = $row['TRANSTYPE_PRICE'];
            $tran_type = $row['TRANSTYPE_NAME'];
            $hourOut = (int) substr($row['TICKETTRANS_TIMEOUT'], 0, 2);
            $hourIn = (int) substr($row['TICKETTRANS_TIMEIN'], 0, 2);
            $extraOut = (int) substr($row['TICKETTRANS_TIMEOUT'], 3, 2);
            $extraIn = (int) substr($row['TICKETTRANS_TIMEIN'], 3, 2);
            $price = ($hourIn - $hourOut) * $tran_price;
            // ราคาต้องดึงมาจาก trans_Type table
            if ($extraIn - $extraOut > 0) {
                $price += $tran_price;
            }
            if ($extraIn - $extraOut == 0 && $hourIn - $hourOut == 0 && (int) substr($row['TICKETTRANS_TIMEOUT'], 6, 2) != (int) substr($row['TICKETTRANS_TIMEIN'], 6, 2)) {
                $price += $tran_price;
            }
            if ($stmt) {
                // echo "Insert successfully!!";
                echo "<script>alert('Price of {$tran_type} is {$price}');window.location='TranspotationIN.php';</script>";
                //header("Refresh:0; url=TranspotationIN.php");
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error($stmt));
            }
        }
        db2_free_stmt($rc);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #11
0
 /**
  * This function initializes the class.
  *
  * @access public
  * @override
  * @param DB_Connection_Driver $connection  the connection to be used
  * @param string $sql                       the SQL statement to be queried
  * @param integer $mode                     the execution mode to be used
  * @throws Throwable_SQL_Exception          indicates that the query failed
  *
  * @see http://www.php.net/manual/en/function.db2-prepare.php
  * @see http://www.php.net/manual/en/function.db2-execute.php
  * @see http://www.php.net/manual/en/function.db2-stmt-error.php
  */
 public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL)
 {
     $resource = $connection->get_resource();
     $command = @db2_prepare($resource, $sql);
     if ($command === FALSE) {
         throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @db2_conn_errormsg($resource)));
     }
     if (!@db2_execute($command)) {
         throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @db2_stmt_errormsg($command)));
     }
     $this->command = $command;
     $this->record = FALSE;
 }
Example #12
0
function insertUselog()
{
    //print_r($_POST);
    if (isset($_POST)) {
        $equipid = $_POST['equipid'];
        $equipname = $_POST['equipname'];
        $empid = $_POST['empid'];
        $zoneid = $_POST['zoneid'];
        $borrowdate = $_POST['borrowdate'];
        $returndate = $_POST['returndate'];
        // an array that want to insert this can be multiple array at the time.
        $data = array($equipid, $equipname, $empid, $zoneid);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        $sql = 'INSERT INTO EMM_ZOO.SANI_EQUIPUSELOG (EQUIPID, EMPID, WORKZONEID, BORROWDATE, RETURNDATE) VALUES (?,?,?,?,?);';
        //$sql2 = 'INSERT INTO EMM_ZOO.EMP_SANI (EMPID) VALUES (?);';
        //echo $sql;
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added to Equipment use log";
                //echo "Successfully added";
                echo "<script>";
                echo "alert('Added successfully')";
                echo "</script>";
                header('Location: addUselogHome.php');
                exit;
            } else {
                $resultMessage = "Failed to query into database";
                echo "<script>";
                echo "alert('Failed to query into database')";
                echo "</script>";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error());
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Example #13
0
function insertEmpAtt()
{
    //print_r($_POST);
    if (isset($_POST)) {
        $attno = $_POST['attno'];
        $dates = $_POST['dates'];
        $empid = $_POST['empid'];
        $workzoneid = $_POST['workzoneid'];
        $dutyid = $_POST['carplate'];
        $starttime = $_POST['starttime'];
        $endtime = $_POST['endtime'];
        // an array that want to insert this can be multiple array at the time.
        $data = array($attno, $dates, $empid, $workzoneid, $dutyid, $starttime, $endtime);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        $sql = 'INSERT INTO EMM_ZOO.SANIEMP_ATTEND (ATTENDNO, DATES, EMPID, WORKZONEID, DUTYID, STARTTIME, ENDTIME) VALUES (?,?,?,?,?,?,?);';
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added to sanitation car";
                //echo "Successfully added";
                echo "<script>";
                echo "alert('Added successfully')";
                echo "</script>";
                header('Location: addCarHome.php');
                exit;
            } else {
                $resultMessage = "Failed to query into database";
                echo "<script>";
                echo "alert('Failed to query into database')";
                echo "</script>";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error());
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Example #14
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $type[0] = $_POST['typeC'];
        $type[1] = $_POST['typeA'];
        $type[2] = $_POST['typeF'];
        $num[0] = intval($_POST['TicketNumC']);
        $num[1] = intval($_POST['TicketNumA']);
        $num[2] = intval($_POST['TicketNumF']);
        //$num = $_POST['TicketNum'];
    }
    // start connect db
    $conn = dbConnect();
    if ($conn) {
        //Part one select data from tickettype
        for ($i = 0; $i <= 2; $i++) {
            if ($num[$i] == 0) {
                continue;
            }
            $sql = "SELECT * FROM EMM_ZOO.TICKETGATE_TYPE WHERE TICKETGATE_TYPE = '{$type[$i]}';";
            $stmt = db2_prepare($conn, $sql);
            $result = db2_execute($stmt);
            while ($row = db2_fetch_assoc($stmt)) {
                $ticket_price = $row['TICKETGATETYPE_PRICE'];
                $ticket_type = $row['TICKETGATE_TYPE'];
                $ticket_id = intval($row['TICKETGATETYPE_ID']);
                //printf ("%-5d %-16s %-32d\n",
                //   $ticket_price, $ticket_type, $ticket_id);
            }
            $insert = "INSERT INTO EMM_ZOO.TICKETGATE_TRANSACTION (TICKETGATE_ID, TICKETGATETYPE_ID, TICKETGATE_DATE, TICKETGATE_NUM, TICKETGATE_PRICE) VALUES (DEFAULT, {$ticket_id}, CURRENT DATE, {$num[$i]}" . "," . $ticket_price * $num[$i] . ");";
            //echo $insert;
            $rc = db2_exec($conn, $insert);
            // ตรงนี้ error ยังไม่เสร็จ
            if ($rc) {
                // echo "Insert successfully!!";
                echo "<script>alert('{$num[$i]} {$type[$i]} ticket has sole  in price " . $ticket_price * $num[$i] . "');window.location='GateTricket.php';</script>";
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error($stmt));
            }
            // finish all query statement
            db2_free_stmt($stmt);
        }
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #15
0
function uploadPubMedInfo()
{
    if (!isset($_SESSION['current_user_name']) && !isset($_COOKIE[$cookie_name])) {
        header('Location: ../login.php');
        exit;
    } else {
        //print_r($_POST);
        if (isset($_POST)) {
            $PUBMEDID = $_POST['PUBMEDID'];
            $Title = $_POST['Title'];
            $Year = $_POST['Year'];
            $Author = $_POST['Author'];
            $Journal = $_POST['Journal'];
            $ResearchType = $_POST['ResearchType'];
            $data = array($PUBMEDID, $Title, $Year, $Author, $Journal, $ResearchType);
            // print var_dump to display an array of variable data with type that prepare for query.
            //echo var_dump($data) ."<br>";
        }
        require_once '/var/www/html/app/model/connect.php';
        $conn = dbConnect();
        if ($conn) {
            // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
            $sql = 'INSERT INTO EMM_ZOO.PUBMEDREFERENCES (PUBMEDID,TITLE,YEAR,AUTHOR,JOURNAL,RESEARCH_TYPE) VALUES (?,?,?,?,?,?);';
            //echo $sql;
            // prepare statement using connection and sql
            $stmt = db2_prepare($conn, $sql);
            // If statement is valid execute it to db2
            if ($stmt) {
                //echo "SQL is valid<br>";
                $result = db2_execute($stmt, $data);
                if ($result) {
                    $resultMessage = "Successfully added to Biological information";
                    echo "Successfully added";
                    header('Location: PubMedRef.php');
                    exit;
                } else {
                    $resultMessage = "Failed to query into database";
                }
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error());
            }
            db2_free_stmt($stmt);
            db2_close($conn);
        } else {
            echo db2_conn_errormsg();
        }
    }
}
Example #16
0
function insertSaniEquip()
{
    //print_r($_POST);
    if (isset($_POST)) {
        $equipid = $_POST['equipid'];
        $equipname = $_POST['equipname'];
        $equiptype = $_POST['equiptype'];
        $status = 'Available';
        // an array that want to insert this can be multiple array at the time.
        $data = array($equipid, $equipname, $equiptype, $status);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        $sql = 'INSERT INTO EMM_ZOO.SANITATION_EQUIP (EQUIPID, EQUIPNAME, EQUIPTYPE, STATUS) VALUES (?,?,?,?);';
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added to sanitation equipment";
                //echo "Successfully added";
                echo "<script>";
                echo "alert('Added successfully')";
                echo "</script>";
                header('Location: addEquipHome.php');
                exit;
            } else {
                $resultMessage = "Failed to query into database";
                echo "<script>";
                echo "alert('Failed to query into database')";
                echo "</script>";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error());
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Example #17
0
function carReturn()
{
    $up = "Y";
    if (isset($_POST)) {
        $empID = $_POST['empID'];
        $carID = $_POST['carID'];
        // an array that want to insert this can be multiple array at the time.
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
        $delete = "DELETE FROM EMM_ZOO.CARS_BORROWED WHERE EMM_ZOO.CARS_BORROWED.CARID = '" . $carID . "';";
        $update = "UPDATE EMM_ZOO.CARS SET EMM_ZOO.CARS.AVAILABLE = '" . $up . "' WHERE EMM_ZOO.CARS.CARID = '" . $carID . "';";
        $guanteen = "SELECT AVAILABLE FROM EMM_ZOO.CARS WHERE EMM_ZOO.CARS.CARID = '" . $carID . "';";
        $ans = dbQuery($conn, $guanteen);
        $row = dbFetchArray($conn, $ans);
        if ($row[0] == 'Y' || $row[0] == 'y') {
            echo "<script type='text/javascript'>alert(' This car has not been borrowed yet');</script>";
            header("Refresh:0; url=returnCar.php");
        } else {
            $result = db2_exec($conn, $delete);
            if ($result) {
                $result2 = db2_exec($conn, $update);
                if ($result2) {
                    echo "<script type='text/javascript'>alert('CAR RETURNED');</script>";
                    header("Refresh:0; url=returnCar.php");
                } else {
                    echo "<script type='text/javascript'>alert('You need to fill all input OR Your employeeID,carID does not exist');</script>";
                    header("Refresh:0; url=TransportationEmployee.php");
                }
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error($stmt));
            }
            db2_free_stmt($result);
            db2_free_stmt($result2);
        }
        db2_free_stmt($ans);
        db2_free_stmt($row);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #18
0
function CharacterUpload()
{
    if (isset($_POST)) {
        $AnimalID = $_POST['AnimalID'];
        $RecordID = $_POST['RecordID'];
        $EmpID = $_POST['EmpID'];
        $Height = $_POST['Height'];
        $Weight = $_POST['Weight'];
        $Length = $_POST['Length'];
        $Pattern = $_POST['Pattern'];
        $BodyTemperature = $_POST['BodyTemperature'];
        // an array that want to insert this can be multiple array at the time.
        $data = array($AnimalID, $RecordID, $EmpID, $Height, $Weight, $Length, $Pattern, $BodyTemperature);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    $conn = dbConnect();
    if ($conn) {
        // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
        $sql = "INSERT INTO EMM_ZOO.ANIMAL_CHARACTORISTICS (ANIMALID, RECORDID, EMPID, HEIGHT, WEIGHT, LENGTH, PATTERN, BODYTEMP) VALUES (?,?,?,?,?,?,?,?);";
        echo $sql;
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added to Biological information";
                echo "Successfully added";
                header('Location: AnimalCharacter.php');
                exit;
            } else {
                $resultMessage = "Failed to query into database";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error());
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Example #19
0
function uploadPromotion()
{
    if (isset($_POST)) {
        $PromoName = $_POST['PromoName'];
        $PromoID = $_POST['PromoID'];
        $ProStart = $_POST['ProStart'];
        $ProEnd = $_POST['ProEnd'];
        $ProductNO = $_POST['ProductNO'];
        $PromType = $_POST['PromType'];
        // an array that want to insert this can be multiple array at the time.
        $data = array($PromoID, $ProStart, $ProEnd, $ProductNO, $PromType, $PromoName);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
        $sql = 'INSERT INTO EMM_ZOO.PROMOTION(PROMOID, PROSTART, PROEND, PRODUCTNO, PROTYPE,PROMONAME) VALUES (?,?,?,?,?,?);';
        echo $sql;
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added to parking reserved";
                //echo "Successfully added";
                header("Refresh:0; url=promotion.php");
                // you must refresh page after insert, define specific page you want to refresh , header("Refresh:0"); it mean refresh current page
            } else {
                $resultMessage = "Failed to query into database";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #20
0
function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true)
{
    if ($show_errors) {
        error_reporting(E_ALL);
    } else {
        error_reporting(E_PARSE);
    }
    // Connect to the IBM DB2 database management system
    $link = db2_pconnect("testdb", "db2inst1", "testpass");
    if (!$link) {
        die(db2_conn_errormsg());
    }
    // Print results in HTML
    print "<html><body>\n";
    // Print SQL query to test sqlmap '--string' command line option
    //print "<b>SQL query:</b> " . $query . "<br>\n";
    // Perform SQL injection affected query
    $stmt = db2_prepare($link, $query);
    $result = db2_execute($stmt);
    if (!$result) {
        if ($show_errors) {
            print "<b>SQL error:</b> " . db2_stmt_errormsg($stmt) . "<br>\n";
        }
        exit(1);
    }
    if (!$show_output) {
        exit(1);
    }
    print "<b>SQL results:</b>\n";
    print "<table border=\"1\">\n";
    while ($line = db2_fetch_array($stmt)) {
        print "<tr>";
        foreach ($line as $col_value) {
            print "<td>" . $col_value . "</td>";
        }
        print "</tr>\n";
        if (!$all_results) {
            break;
        }
    }
    print "</table>\n";
    print "</body></html>";
}
Example #21
0
function query($sql, $conn)
{
    try {
        $result = db2_exec($conn, $sql);
        $count = 0;
        while ($row = db2_fetch_object($result)) {
            echo $row->NAME1 . ", " . $row->NAME2 . " " . $row->STREET . ", " . $row->CITY . ", " . $row->STATE . ", " . $row->ZIP . ", " . $row->COUNTY . ", " . $row->LONG . ", " . $row->LAT . "<br>";
            $count++;
        }
        //print_r($result);
        if ($result) {
            echo "Query Successful<br>" . $count . " total entries<br>";
        }
    } catch (Exception $e) {
        echo "Query Failed<br>";
        echo "Exception: " . $e->getMessage() . "<br>";
        echo db2_conn_error() . "<br>";
        echo db2_conn_errormsg() . "<br>";
    }
}
Example #22
0
function other()
{
    if (isset($_POST)) {
        $type = $_POST['type'];
        $empID = $_POST['empID'];
        $start = $_POST['start'];
        $end = $_POST['end'];
        // an array that want to insert this can be multiple array at the time.
        $data = array($empID, $type, $start, $end);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
        $sql = 'INSERT INTO EMM_ZOO.VEHICLE_BORROW(BORROWVEHICLEID,VEHICLE_TYPE,STARTDATE,ENDDATE) VALUES (?,?,?,?);';
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added to parking reserved";
                //echo "Successfully added";
                header("Refresh:0; url=tey.php");
                // you must refresh page after insert, define specific page you want to refresh , header("Refresh:0"); it mean refresh current page
            } else {
                $resultMessage = "Failed to query into database";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #23
0
function addempani()
{
    echo "addempani() called";
    if (isset($_POST)) {
        $empid = $_POST['empid'];
        $aniid = $_POST['aniid'];
        $start = $_POST['std'];
        $end = $_POST['end'];
        // an array that want to insert this can be multiple array at the time.
        $data = array($empid, $aniid, $start, $end);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
        $sql = 'INSERT INTO EMM_ZOO.EMPFORANIMAL (EMPID, ANIMALID, EMPCARESTART, EMPCAREEND) VALUES (?,?,?,?);';
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added employee responsibility";
                // header("Refresh:0; url=index.php"); // you must refresh page after insert, define specific page you want to refresh , header("Refresh:0"); it mean refresh current page
            } else {
                $resultMessage = "Failed to query into database";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        db2_free_stmt($stmt);
        // db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #24
0
function editEmployeeInfo()
{
    if (isset($_POST)) {
        $empid = $_POST['update_empid'];
        $jobid = $_POST['edit_jobid'];
        $firstname = $_POST['edit_firstname'];
        $lastname = $_POST['edit_lastname'];
        $birthdate = $_POST['edit_birthdate'];
        $sex = $_POST['edit_sex'];
        $nationality = $_POST['edit_nationality'];
        $hiredate = $_POST['edit_hiredate'];
        $address = $_POST['edit_address'];
        $email = $_POST['edit_email'];
        $phone = $_POST['edit_phone'];
        $salary = $_POST['edit_salary'];
        $bonus = $_POST['edit_bonus'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.EMPLOYEE SET EMPID = '{$empid}', JOBID = '{$jobid}', FIRSTNAME = '{$firstname}', LASTNAME = '{$lastname}', BIRTHDATE = '{$birthdate}', SEX = '{$sex}', NATIONALITY = '{$nationality}', HIREDATE = '{$hiredate}', ADDRESS = '{$address}', EMAIL = '{$email}', PHONE = '{$phone}' , SALARY = '{$salary}', BONUS = '{$bonus}' WHERE EMPID = {$empid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_emp.php#emp_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
Example #25
0
 public function open()
 {
     if (!empty($GLOBALS['phpopenfw_db2_conn']) && is_resource($GLOBALS['phpopenfw_db2_conn']) && !$this->handle) {
         $this->handle = $GLOBALS['phpopenfw_db2_conn'];
     } else {
         if (!$this->handle) {
             $conn_str = "\n\t\t\t\tDRIVER={IBM DB2 ODBC DRIVER};\n\t\t\t\tDATABASE={$this->source};\n\t\t\t\tHOSTNAME={$this->server};\n\t\t\t\tPORT={$this->port};\n\t\t\t\tPROTOCOL=TCPIP;\n\t\t\t\tUID={$this->user};\n\t\t\t\tPWD={$this->pass};\n\t\t\t";
             // Connection String
             if ($this->conn_str !== false) {
                 $db_params = (string) $this->conn_str;
                 if ($this->persistent) {
                     $this->handle = !empty($this->options) ? db2_pconnect($db_params, '', '', $this->options) : db2_pconnect($db_params, '', '');
                 } else {
                     $this->handle = !empty($this->options) ? db2_connect($db_params, '', '', $this->options) : db2_connect($db_params, '', '');
                 }
             } else {
                 if ($this->persistent) {
                     $this->handle = !empty($this->options) ? db2_pconnect($this->source, $this->user, $this->pass, $this->options) : db2_pconnect($this->source, $this->user, $this->pass);
                 } else {
                     $this->handle = !empty($this->options) ? db2_connect($this->source, $this->user, $this->pass, $this->options) : db2_connect($this->source, $this->user, $this->pass);
                 }
             }
             if (db2_conn_errormsg()) {
                 $this->connection_error(db2_conn_errormsg());
                 $this->handle = false;
                 return false;
             }
             // Keep track of the number of connections we create
             $this->increment_counters();
         }
     }
     // Flag Connection as Open
     $this->conn_open = true;
     // Start Transaction and Turn off Auto Commit?
     if (!$this->auto_commit && !$this->trans_started) {
         db2_autocommit($this->handle, DB2_AUTOCOMMIT_OFF);
         $this->start_trans();
     }
     return true;
 }
Example #26
0
function addRound()
{
    if (isset($_POST)) {
        $showID = $_POST['showID'];
        $roundID = $_POST['roundID'];
        $starttime = $_POST['starttime'];
        $endtime = $_POST['endtime'];
        $showdate = $_POST['showdate'];
    }
    $conn = dbConnect();
    if ($conn) {
        $insert = "INSERT INTO EMM_ZOO.SHOW_TIMETABLE(SHOWID, ROUNDID, STARTTIME, ENDTIME, DATES) values({$showID}, {$roundID}, '{$starttime}', '{$endtime}', '{$showdate}');";
        //$insert = "INSERT INTO EMM_ZOO.SHOW_TIMETABLE(SHOWID, ROUNDID, STARTTIME, ENDTIME, DATES) values(1, 3, '16:00:00', '16:30:00', '11/12/2015');";
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            echo "Insert Successful";
        } else {
            die('Critical error: ' . db2_stmt_error($rc));
        }
        $sql = "SELECT * from EMM_ZOO.SHOW WHERE SHOWID = {$showID};";
        $stmt = db2_prepare($conn, $sql);
        $result = db2_execute($stmt);
        while ($row = db2_fetch_assoc($stmt)) {
            $zone = $row['BUILDINGID'];
            $name = $row['SHOWNAME'];
        }
        $insert = "INSERT INTO EMM_ZOO.SHOW_TICKET(SHOWID, STARTTIME, ENDTIME, DATES, SHOWNAME, ZONEID) values({$showID}, '{$starttime}', '{$endtime}', '{$showdate}', '{$name}', {$zone});";
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            echo "Insert Successful";
        } else {
            die('Critical error: ' . db2_stmt_error($rc));
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #27
0
 /**
  * 
  * 
  * @todo Throw in your "transport/adapter" framework for a real OO look and feel ....
  * Throw new Exception("Fail execute ($sql) ".db2_stmt_errormsg(),db2_stmt_error());
  * ... and retrieve via try/catch + Exception methods.
  *
  * @param $database
  * @param $user
  * @param $password
  * @param null $options 'persistent' is one option
  * @return bool
  */
 public function connect($database, $user, $password, $options = null)
 {
     // Compensate for older ibm_db2 driver that may not do this check.
     if ($user && empty($password)) {
         $this->setErrorCode('08001');
         $this->setErrorMsg('Authorization failure on distributed database connection attempt. SQLCODE=-30082');
         return false;
     }
     if ($options) {
         if (isset($options['persistent']) && $options['persistent']) {
             $conn = db2_pconnect($database, $user, $password);
         } else {
             $conn = db2_connect($database, $user, $password);
         }
         if (is_resource($conn)) {
             return $conn;
         }
     }
     $this->setErrorCode(db2_conn_error());
     $this->setErrorMsg(db2_conn_errormsg());
     return false;
 }
Example #28
0
function addRound()
{
    if (isset($_POST)) {
        $showID = $_POST['showID'];
        $roundID = $_POST['roundID'];
        $starttime = $_POST['starttime'];
        $endtime = $_POST['endtime'];
        $showdate = $_POST['showdate'];
    }
    $conn = dbConnect();
    if ($conn) {
        //$insert = "Update";
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            echo "Insert Successful";
        } else {
            die('Critical error: ' . db2_stmt_error($rc));
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #29
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $type = $_POST['type'];
    }
    // start connect db
    $conn = dbConnect();
    if ($conn) {
        //Part one select data from tickettype
        $sql = "SELECT * FROM EMM_ZOO.TICKETTRANS_TYPE WHERE TRANSTYPE_NAME = '{$type}';";
        //echo $sql;
        $stmt = db2_prepare($conn, $sql);
        $result = db2_execute($stmt);
        while ($row = db2_fetch_assoc($stmt)) {
            $tran_price = $row['TRANSTYPE_PRICE'];
            $tran_type = $row['TRANSTYPE_NAME'];
            $tran_id = $row['TRANSTYPE_ID'];
            // printf ("%-5d %-16s %-32d\n",
            //    $tran_price, $tran_type, $tran_id);
        }
        $insert = " INSERT INTO EMM_ZOO.TICKETTRANS_TRANSACTION (TICKETTRANS_ID, VEHICLETRANS_ID, TICKETTRANS_DATE , TICKETTRANS_TIMEIN ,TICKETTRANS_TIMEOUT) VALUES (DEFAULT, '{$tran_id}',CURRENT DATE , NULL, CURRENT TIME);";
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            echo "<script>alert('1 {$tran_type} has rent');window.location='TranspotationTricket.php';</script>";
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
Example #30
0
function addEmp2()
{
    if (isset($_POST)) {
        $EmpID = $_POST['employeeAdd'];
        // an array that want to insert this can be multiple array at the time.
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "INSERT INTO EMM_ZOO.MAINTEGERAINPERSON (MPSNO, EMPID, REQUESTID) VALUES ({$EmpID}, {$EmpID} ,0);";
        //$sql2 = 'INSERT INTO EMM_ZOO.EMP_SANI (EMPID) VALUES (?);';
        //echo $sql;
        // prepare statement using connection and sql
        // If statement is valid execute it to db2
        //echo "SQL is valid<br>";
        $result = db2_exec($conn, $sql);
        if ($result) {
            $resultMessage = "Successfully added to maintainance personel";
            //echo "Successfully added";
            echo "<script>";
            echo "alert('Added successfully')";
            echo "</script>";
            header("Refresh:0; url=team.php");
            exit;
        } else {
            $resultMessage = "Failed to query into database";
            echo "<script>";
            echo "alert('Failed to query into database')";
            echo "</script>";
            header("Refresh:0; url=team.php");
        }
        db2_free_stmt($result);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}