首页 > 解决方案 > 在同一页面上渲染成功或失败 REMINDER HERE

问题描述

我的错误或成功消息不在正确的位置,所以我想知道如何在正确的位置获取我的消息。

我一直在网上搜索。我找不到正确的解决方案。

这是我的意思的照片。

在此处输入图像描述

<!DOCTYPE html>
<?php include('import_excel.php') ?>
<?php include('functions.php') ?>
<html lang="en" class=""><head>
  <meta name="ac:base" content="/C:/xampp/htdocs/Angular-421-N-WORK-APP">
  <meta charset="utf-8">
  <title>N-WORK-USER | opslag-Sorting</title>
  <meta name="description" content="app, web app, responsive, responsive layout, admin, admin panel, admin dashboard, flat, flat ui, ui kit, AngularJS, ui route, charts, widgets, components">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../libs/assets/animate.css/animate.css" type="text/css">
  <link rel="stylesheet" href="../libs/assets/font-awesome/css/font-awesome.min.css" type="text/css">
  <link rel="stylesheet" href="../libs/assets/simple-line-icons/css/simple-line-icons.css" type="text/css">
  <link rel="stylesheet" href="../libs/jquery/bootstrap/dist/css/bootstrap.css" type="text/css">
  <link rel="stylesheet" href="css/app.min.css" type="text/css">
  <link rel="stylesheet" type="text/css" href="css/component.css">
  <script>
          (function(e,t,n){
            var r=e.querySelectorAll("html")[0];r.className=r.className.replace(/(^|\s)no-js(\s|$)/,"$1js$2");
          }
           
        (document,window,0)
          );                         
  </script>
  
</head>
<body>
  <!-- content -->
  <div id="content" class="app-content" role="main">
    <div class="app-content-body ">

    <div ng-controller="FullcalendarCtrl">
    <!-- main header -->
  <div class="wrapper-md bg-yello b-b">    
    <h1 class="m-n font-thin h3">Lijst werkkracht TL GL Database</h1>
  </div>
    <!-- / main header -->
<div class="wrapper-md" ng-controller="FormDemoCtrl">
  <div class="panel panel-defaultgrd">
    <div class="panel-headinggrd font-bold text-blue">
      Uitslag
    </div>
  <div class="panel-body">
  <div class="hbox hbox-auto-xs hbox-auto-sm">
    <div class="container">
      <div class="row">
       <div class="col-md-12 control-label">             
        <a href="form_werkkracht_database.php"><button class="btn btn-info">Database invoegen</button></a>
        <a class="btn btnx btn-orange" id="download-btn" target="_new"><i class="fa fa-download"></i> Export to Excel</a>
       <form method="post" action="import_excel.php" enctype="multipart/form-data">      
       <div class="form-groupp" style="">            
        <input type="file" name="file-7" id="file-7" class="inputfile inputfile-6" data-multiple-caption="{count} files selected" multiple=""><label for="file-7"><span></span> <strong><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"></path></svg> Import Excel..</strong></label>
        </div>
        <a class="btnl"><button class="btn btn-info" style="">Upload</button></a>
         </form>
        
         <div class="table-responsive">                 
      <table id="mytable" class="table table-bordred table-striped">                 
         <thead>
           <tr>
           <th>#</th>
           <th>MBU</th>
           <th>Zone</th>
           <th>Omschrijving</th>
           <th>TL</th>
           <th>GL</th>
           <th>Stand in lijn</th>
           <th>Station</th>
           <th>MBU nr</th>
           <th>WO stap</th>
           <th>LOG stap</th>
           <th>Q stap</th>
           <th>RA stand</th>           
           <th>Edit</th>
           <th>Delete</th>
           </tr>
         </thead>
       <tbody>         
<?php
      $fetchdata=new DB_con(); 
      $sql=$fetchdata->fetchdata();
      $cnt=1;
         while($row=mysqli_fetch_array($sql))
           
     {
?>          
       <tr>       
       <td><?php echo htmlentities($cnt);?></td>
       <td><?php echo htmlentities($row['MBU']);?></td>
       <td><?php echo htmlentities($row['zone']);?></td>
       <td><?php echo htmlentities($row['omschr']);?></td>
       <td><?php echo htmlentities($row['tl']);?></td>
       <td><?php echo htmlentities($row['gl']);?></td>
       <td><?php echo htmlentities($row['stand_in_lijn']);?></td>
       <td><?php echo htmlentities($row['station']);?></td>
       <td><?php echo htmlentities($row['MBU_nr']);?></td>
       <td><?php echo htmlentities($row['WO_stap']);?></td>
       <td><?php echo htmlentities($row['LOG_stap']);?></td>
       <td><?php echo htmlentities($row['Q_stap']);?></td>
       <td><?php echo htmlentities($row['RA_stand']);?></td>       
       <td><a href="updat_form_database_tl_gl.php?id=<?php echo htmlentities($row['id']);?>"><button class="btn btn-info btn-xs"><span class="glyphicon glyphicon-pencil"></span></button></a></td>

       <td><a href="app_opslag_database_tl_gl.php?del=<?php echo htmlentities($row['id']);?>"><button class="btn btn-danger btn-xs" onclick="return confirm('Wil je bestand echt verwijderen?');"><span class="glyphicon glyphicon-trash"></span></button></a></td>
    </tr>
<?php 
// for serial number increment
     $cnt++;
   } 
?>
       </tbody>      
     </table>
      </div>
        </div>
          </div>
            </div>
          </div>
       </div>
    </div>
</div>
</div>
  <!-- / main --> 
</div>  
  </div>      
  <!-- /content -->
  
  <!-- footer -->
  <footer id="footer" class="app-footer" role="footer">
    <div class="wrapper b-t bg-light">
      <span class="pull-right">2.3.0 <a href="#" ui-scroll="app" class="m-l-sm text-muted"><i class="fa fa-long-arrow-up"></i></a></span>
      © 2018 Copyright.
    </div>
  </footer>
  <!-- / footer --> 
<script src="js/app.min.js"></script>
</body>
</html>

我的其他代码 import_excel.php

<?php
/**
 * RaeCreated by Homensdigiworld.
 * Admin: Stefaan
 * Date: 26-03-2019
 */
include_once "app_opslag_database_tl_gl.php";
use Box\Spout\Reader\ReaderFactory;
use Box\Spout\Common\Type;

require_once ('connect.php');
require_once ('Spout/Autoloader/autoload.php');

if(!empty($_FILES['file-7']['name']))
{
    // Get File extension eg. 'xlsx' to check file is excel sheet
    $pathinfo = pathinfo($_FILES['file-7']['name']);

    // check file has extension xlsx, xls and also check
    // file is not empty
    if (($pathinfo['extension'] == 'xlsx' || $pathinfo['extension'] == 'xls')
        && $_FILES['file-7']['size'] > 0 )
    {
        $file = $_FILES['file-7']['tmp_name'];

        // Read excel file by using ReadFactory object.
        $reader = ReaderFactory::create(Type::XLSX);

        // Open file
        $reader->open($file);
        $count = 0;

        // Number of sheet in excel file
        foreach ($reader->getSheetIterator() as $sheet)
        {

            // Number of Rows in Excel sheet
            foreach ($sheet->getRowIterator() as $row)
            {

                // It reads data after header. In the my excel sheet,
                // header is in the first row.
                if ($count > 0) {

                    // Data of excel sheet
                    $MBU = $row[1];
                    $zone = $row[2];
                    $omschr = $row[3];
                    $tl = $row[4];
                    $gl = $row[5];
                    $stand_in_lijn = $row[6];
                    $station = $row[7];
                    $MBU_nr = $row[8];
                    $WO_stap = $row[9];
                    $LOG_stap = $row[10];
                    $Q_stap = $row[11];
                    $RA_stand = $row[12];

                    //Here, You can insert data into database.
                    $qry = "INSERT INTO `users`(`MBU`, `zone`, `omschr`, `tl`, `gl`, `stand_in_lijn`, `station`, `MBU_nr`, `WO_stap`, `LOG_stap`, `Q_stap`, `RA_stand`) VALUES ('$MBU','$zone','$omschr','$tl','$gl','$stand_in_lijn','$station','$MBU_nr','$WO_stap','$LOG_stap','$Q_stap','$RA_stand')";
                    $res = mysqli_query($con,$qry);

                }
                $count++;
            }
        }

        if($res)
        {
            
            echo "Your file Uploaded Successfull";
        }
        else
        {
            echo "Your file Uploaded Failed";
        }

        // Close excel file
        $reader->close();
    }
    else
    {
        echo "Please Choose only Excel file";
    }
}
else
{
    echo "File is Empty"."<br>";
    echo "Please Choose Excel file";
}

?>

我有这条消息:未定义的变量:第 29 行 C:\xampp\htdocs\import-excel_08\index.php 中的 _SESSION

标签: phphtml

解决方案


您将上传文件包含在主页文件的顶部。

<?php include('import_excel.php') ?>

不需要包含它,因为它在该页面上什么都不做,您的表单提交到该文件。

从该页面的顶部将其删除,该消息应该会消失。


推荐阅读