我无法将数据插入我的数据库

时间:2016-12-19 17:02:14

标签: php html mysql sql html5

我是php的新手,我无法弄清楚为什么我无法将数据插入到我的数据库中,这甚至都不会显示错误。我不知道我在哪里做错了代码。非常感谢快速解决方案

<!DOCTYPE html>
<html>


<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Send Document</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.6 -->
  <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
  <!-- Morris chart -->
  <link rel="stylesheet" href="plugins/morris/morris.css">
  <!-- jvectormap -->
  <link rel="stylesheet" href="plugins/jvectormap/jquery-jvectormap-1.2.2.css">
  <!-- Date Picker -->
  <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css">
  <!-- bootstrap wysihtml5 - text editor -->
  <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
  <link rel="stylesheet" href="fonts/material-icons.css">
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <script src="JavaScripts/jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>



<body class="hold-transition skin-blue sidebar-mini">
<form action="managedoc.php" id="docDetails" method="POST" name="frmImage" enctype="multipart/form-data">
<div class="wrapper">

  <header class="main-header">
    <!-- Logo -->
    <a href="managedoc.php" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><b>C</b>S</span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>Tracking</b>System</span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
      <span class="sr-only">Toggle navigation</span>
      </a>

        <?php 
            include 'session.php';

<html>
  <form method="POST">
  
  <?php
if(isset($_POST['submit'])) {
include 'db1.php';

$officeRel=mysql_query("SELECT o.officeid as office FROM office o inner join user u on o.officeid=u.officeid Where u.staffid = '".$_SESSION['staffid']."'");
$docCodee=$_POST['docCode'];
$docType = $_POST['docType'];
$staffidd=$_POST['staffid'];



$sql2 = "INSERT into archive (docCode, staffidReleased, statusReleased, dateReleased, staffidReceived, statusReceived, dateReceived, officeRel, officeRec, datemodified) values ('$docCodee', '".$_SESSION['staffid']."', 'Released', NOW(), '$staffidd', 'On the way', ' ', '$officeRel', '$docType', ' ')";


if ($conn->query($sql2) === TRUE) {
  echo $sql2;

} else {
    echo "Error: " . $sql2 . "<br>" . $conn->error;
}

$conn->close();
}
?>



<?php
include 'db3.php';
$id = $_GET['id'];

  $sql3 = "SELECT * FROM document Where docCode = '$id'";
   mysql_select_db('docutrack');
   $retval3 = mysql_query( $sql3, $conn );
   
   if(! $retval3 ) {
      die('Could not get data: ' . mysql_error());
   }
   
   while($row3 = mysql_fetch_array($retval3, MYSQL_ASSOC)) {


$docode = $row3['docCode'];

   }
   
   
   mysql_close($conn);
?>

  
       <center>
        <table width="50%" cellpadding="5" cellspacing="3">


                <tr>
      <td>
                        <select class="form-control" name="docType" onchange="setDoc(document.Form, this.value);"> 
                          <option selected>--Select Office--</option>
                          <?php
                                            include 'db2.php';

                                            $query= "SELECT officeid, officename FROM office ";
                                            $list = mysql_query($query);

                                            while ($row_list=mysql_fetch_array($list))
                                            {
                                                printf ("<option value=%s>%s</option>", $row_list[0], htmlspecialchars($row_list[1]));
                                            }

                                        ?>
                                        </select>

                      <script>
                        var docCodes = {
                          '--Select Office--': "Staff ID",
                          'AO': "****-****",
                          'ASA': "****-****"

                      </script>

      <tr>
      <td><input type="text" class="form-control" id="showDoc" name="staffid" placeholder="Staff ID" required> </td> <!--name is from update all _POST("") -->
      <td></td>
      </tr>

      <tr>
      <td><input type="text" class="form-control" name="docCode" value="<?php echo "$docode";?> "></td> <!--name is from update all _POST("") -->
      <td></td>
      </tr>
                </table>
                <br>
      
      <td></td><button type="submit" name="submit" class="btn btn-info" onclick="return alert('Succesfully sent!')">Send</button>
  
      </center>
     </form>     
  
  </html>
  

            $query= mysql_query("select * from user where staffid = '$session_id'")or die(mysql_error());
            $row = mysql_fetch_array($query);

            ?>

      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
          <!-- User Account: style can be found in dropdown.less -->
          <li class="dropdown user user-menu">
            <a data-toggle="modal" data-target="#logout">Log Out</a>
            </li>
          <!-- Control Sidebar Toggle Button -->

        </ul>
      </div>
    </nav>
  </header>

     <!-- log out box-->     
                                         <div>   

                                        <div id="logout" class="modal fade" role="dialog">
                                          <div class="modal-dialog modal-sm">
                                            <!-- Modal content-->
                                            <div class="modal-content">
                                              <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                <h4 class="modal-title">Are you sure you want to log out?</h4>
                                              </div>

                                            <div class="modal-footer">
                                                  <button class="btn btn-info" data-dismiss="modal" aria-hidden="true">NO</button>
                                                  <a href="logout.php" class="btn btn-danger">Yes</a>
                                              </div>

                                              </div>   
                                                </div>
                                               </div>
                                            </div>
                                              <!-- /Modal delete box -->


<?php
if(isset($_POST['submit'])) {
include 'db1.php';

$officeRel=mysql_query("SELECT o.officeid as office FROM office o inner join user u on o.officeid=u.officeid Where u.staffid = '".$_SESSION['staffid']."'");
$docCodee=$_POST['docCode'];
$docType = $_POST['docType'];
$staffidd=$_POST['staffid'];



$sql2 = "INSERT into archive (docCode, staffidReleased, statusReleased, dateReleased, staffidReceived, statusReceived, dateReceived, officeRel, officeRec, datemodified) values ('$docCodee', '".$_SESSION['staffid']."', 'Released', NOW(), '$staffidd', 'On the way', ' ', '$officeRel', '$docType', ' ')";


if ($conn->query($sql2) === TRUE) {
  echo $sql2;

} else {
    echo "Error: " . $sql2 . "<br>" . $conn->error;
}

$conn->close();
}
?>



<?php
include 'db3.php';
$id = $_GET['id'];

  $sql3 = "SELECT * FROM document Where docCode = '$id'";
   mysql_select_db('docutrack');
   $retval3 = mysql_query( $sql3, $conn );

   if(! $retval3 ) {
      die('Could not get data: ' . mysql_error());
   }

   while($row3 = mysql_fetch_array($retval3, MYSQL_ASSOC)) {


$docode = $row3['docCode'];

   }


   mysql_close($conn);
?>



  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- Sidebar user panel -->
      <div class="user-panel">
        <div class="pull-left image">
          <img src="dl.png" class="img-circle" alt="User Image">
        </div>
        <div class="pull-left info">
          <p></p>
          <p><?php echo $row['fname']." ".$row['lname']; ?></p>
        </div>
      </div>

      <!-- /.search form -->
      <!-- sidebar menu: : style can be found in sidebar.less -->
      <ul class="sidebar-menu">
        <li class="header">MENU</li>
        <li >
          <a href="managedoc.php">
            <i class="glyphicon glyphicon-file"></i> <span>Manage Documents</span>
            <span class="pull-right-container">
            </span>
          </a>

        </li>

        <li >
          <a href="#">
            <i class="glyphicon glyphicon-transfer"></i> <span>Manage Document Tracking</span>
            <span class="pull-right-container">
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="managedoc.php"><i class="glyphicon glyphicon-send"></i> Send</a></li>
            <li><a href="receive.php"><i class="glyphicon glyphicon-save"></i> Receive</a></li>
            <li><a href="pages/tables/data.html"><i class="glyphicon glyphicon-eye-open"></i> Track</a></li>
          </ul>
          </li>


    </section>
    <!-- /.sidebar -->
  </aside>

   <!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">

  <center>
  <section class="content-header" style="font-size: 24px;">
      Send Document
  </section>
  </center>

  <section class="content">
  <form method="POST">
       <center>
        <table width="50%" cellpadding="5" cellspacing="3">


                <tr>
      <td>
                        <select class="form-control" name="docType" onchange="setDoc(document.Form, this.value);"> 
                          <option selected>--Select Office--</option>
                          <?php
                                            include 'db2.php';

                                            $query= "SELECT officeid, officename FROM office ";
                                            $list = mysql_query($query);

                                            while ($row_list=mysql_fetch_array($list))
                                            {
                                                printf ("<option value=%s>%s</option>", $row_list[0], htmlspecialchars($row_list[1]));
                                            }

                                        ?>
                                        </select>

                      <script>
                        var docCodes = {
                          '--Select Office--': "Staff ID",
                          'AO': "****-****",
                          'ASA': "****-****",


                      };
                      var form = document.getElementById('docDetails');
                      form.elements.docType.onchange = function () {
                          var form = this.form;
                          form.elements.showDoc.value = docCodes[this.value];
                      };

                      </script>

      <tr>
      <td><input type="text" class="form-control" id="showDoc" name="staffid" placeholder="Staff ID" required> </td> <!--name is from update all _POST("") -->
      <td></td>
      </tr>

      <tr>
      <td><input type="text" class="form-control" name="docCode" value="<?php echo "$docode";?> "></td> <!--name is from update all _POST("") -->
      <td></td>
      </tr>
                </table>
                <br>

      <td></td><button type="submit" name="submit" class="btn btn-info" onclick="return alert('Succesfully sent!')">Send</button>

      </center>
     </form>     
  </section> 
</div> 


  <!-- Control Sidebar -->
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- jQuery 2.2.3 -->
<script src="plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.6 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- Morris.js charts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="plugins/morris/morris.min.js"></script>
<!-- Sparkline -->
<script src="plugins/sparkline/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="plugins/knob/jquery.knob.js"></script>
<!-- daterangepicker -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
<script src="plugins/daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
</body>
</html>

这里是插入语句

<?php
if(isset($_POST['submit'])) {
include 'db1.php';

$officeRel=mysql_query("SELECT o.officeid as office 
                        FROM office o 
                        inner join user u on o.officeid=u.officeid 
                        Where u.staffid = '".$_SESSION['staffid']."'");

$docCodee=$_POST['docCode'];
$docType = $_POST['docType'];
$staffidd=$_POST['staffid'];

$sql2 = "INSERT into archive 
         (docCode, staffidReleased, statusReleased, dateReleased,
          staffidReceived, statusReceived, dateReceived, officeRel,
          officeRec, datemodified) 
         values 
         ('$docCodee', '".$_SESSION['staffid']."', 'Released',
         NOW(), '$staffidd', 'On the way', ' ', '$officeRel',
         '$docType', ' ')";

        if ($conn->query($sql2) === TRUE) {
           echo $sql2;
        } else {
           echo "Error: " . $sql2 . "<br>" . $conn->error;
        } 

        $conn->close();
        }
?>

0 个答案:

没有答案