I have a project where I can upload a specific excel-file on a website. The excel-file is shown on the website as a html table. Under the table is a button to upload the table in a database. Therefore I save the table cells in an array (in JS-function). At the end I pass the array to a second php-file, where I upload the array data in a database. On last upload I want to show a pop-up. I have these files:
upload.php
if (isset($_FILES['file']) && !empty($_FILES['file'])) {
//show excel file as table on website
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<button id="exBtnHoch" name="exBtnHoch" onclick="saveInArray()" type="button" class="btn btn-success btn-block">Excel-Datei hochladen</button>
</br></br></br></br></br></br>
</form>
}
excelEinlesen.php
include "pop_up.php";
if(isset($_POST['daten'])){ //checks if array is passed
//if successfull then do something like:
echo '<script type="text/javascript">showPOP_UP();</script>';
}
//EDIT
function a (){} //they are called in the if-part
function b (){}
EDIT: pop_up.php: HTML-Code
<!doctype html>
<html lang="de">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="../css/bootstrap.min.css">
<script type="text/javascript" src="js/excelEinlesen.js"></script>
</head>
<body>
<div class="modal fade" id="pop_upHochgeladen" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Speichern</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Die Daten des Mitarbeiters wurden erfolgreich in die Datenbank geschrieben.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" onClick="geheZuHome()">Zurück zur Startseite</button>
<button type="button" class="btn btn-warning" onClick="window.location.href=window.location.href">Weitere Datei hochladen</button>
</div>
</div>
</div>
</div>
</body>
</html>
AND
excelEinlesen.js
function saveInArray(){
//save table cells in array
//at the end pass array to excelEinlesen.php
}
function showPOP_UP(){
$('#pop_up').modal('show');
}
I tried to echo it and searched the whole internet without any satisfying solutions. First had a second onclick in upload.php and it worked, but I want to call the JS-function in a specific case without onclick.
I don't know if this a problem, but I have different folders for my files: "js" and "php".