0

我需要一些帮助..我希望有人可以帮助我=') ..这是关于删除过程..在删除之前我希望详细信息将首先保存到其他表中..但我不知道如何插入详细信息在删除之前进入“departmenttrail”表。以下是我制作的代码..但此代码不起作用,希望有人能提供帮助..

 <?php
    session_start();
    $popo=$_SESSION['userID'];
    include('Connections/dbconn.php');
    if(isset($_SESSION['userID']) && $_SESSION['userID'] != ""){


    ?>
    <?php require_once('Connections/dbconn.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }

    if ((isset($_GET['valid'])) && ($_GET['valid'] != "")) {

    $inserted_id = $_GET['valid'];

    $sql2 = mysql_query("INSERT INTO departmenttrail (d_no,d_name, d_position, d_staff_name, d_noic_nopassport, d_type_training, d_date_training, d_date_expired, d_sijil) SELECT * FROM department WHERE d_no =".$inserted_id) or die("Error: " . mysql_error());

      $deleteSQL = sprintf("DELETE FROM department WHERE d_no=%s",
                           GetSQLValueString($_GET['valid'], "int"));

      mysql_select_db($database_dbconn, $dbconn);
      $Result1 = mysql_query($deleteSQL, $dbconn) or die(mysql_error());

        print '<script type="text/javascript">'; 
        print 'alert("The details are successfully deleted")'; 
        print '</script>';
        echo "<script language=\"JavaScript\">{                                                                                         
        location.href=\"update(power).php\"                                                                                         
        }</script>";
      if (isset($_SERVER['QUERY_STRING'])) {
        $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
        $deleteGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $deleteGoTo));
      insertAuditTrail(date('Y-m-d H:i:s'),"Module:Delete User" ,"User Details successfully deleted",$_SESSION['userID']); 
    }
    ?>
    <?php 
    }
    else{
        header("Location: index.php");}

    ?>
4

0 回答 0