-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
34 lines (28 loc) · 1.07 KB
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// upload.php
session_start();
if ($_FILES["fileInput"]["error"] == UPLOAD_ERR_OK) {
$fileContent = file_get_contents($_FILES["fileInput"]["tmp_name"]);
$_SESSION['uploadedFile'] = $fileContent;
// Parse the file content and update the database
$fileLines = explode("\n", $fileContent);
foreach ($fileLines as $line) {
$lineData = explode('|', $line);
$clientName = $lineData[0];
$consumption = $lineData[1];
$year = $lineData[2];
// Assuming you have a function to update the database
updateDatabase($clientName, $consumption, $year);
}
header("Location: your-main-file.php"); // Redirect to your main file after processing
} else {
echo "Erreur lors du téléchargement du fichier.";
}
// Function to update the database
function updateDatabase($clientName, $consumption, $year) {
// Implement the logic to update the database
global $con;
$query = "UPDATE facture SET consumption = '$consumption' WHERE client_name = '$clientName' AND year = '$year'";
mysqli_query($con, $query);
}
?>