如果Oracle插入成功失败,PHP重定向

时间:2019-02-27 17:53:43

标签: php oracle oracle11g

我要为成功和不成功的插入设置Bootstrap警报。我四处张望,找不到任何人进行2次重定向的例子,其中一次成功插入,一次失败。

 if(isset($_POST['CountryID'])) {

            $CountryID = $_POST['CountryID'];
            if(isset($_POST['CountryName'])) {
                $CountryName = $_POST['CountryName'];
            }
            if(isset($_POST['GPD'])){
                $GDP = $_POST['GPD'];
            }

            $stmt = oci_parse($conn, "INSERT INTO COUNTRY (COUNTRYNAME, GDP) VALUES (:CountryName, :GDP) WHERE COUNTRYID = :CountryID");

            ocibindbyname($stmt, ":CountryID", $CountryID);
            oci_bind_by_name($stmt, ":CountryName", $CountryName);
            oci_bind_by_name($stmt, ":GDP", $GDP);

            oci_execute($stmt);
            oci_commit($conn);
            oci_free_statement($stmt);

//insert if successful here
            header("Location: ../index.php?Success=Country has been updated!");
//insert else here
            header("Location: ../index.php?Danger=Country update failed!");

    }

2 个答案:

答案 0 :(得分:0)

您需要修复以下查询

INSERT INTO COUNTRY
  (COUNTRYID,COUNTRYNAME, GDP)
VALUES
  (:CountryID,:CountryName, :GDP);

答案 1 :(得分:0)

this.dtOptions.stateSave = false