-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport.php
21 lines (20 loc) · 876 Bytes
/
import.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
include '+koneksi.php';
$idagenda = isset($_GET['idagenda']) ? $_GET['idagenda'] : null;
if(@$_FILES['file_csv']['size'] > 0) {
$fileName = @$_FILES['file_csv']['tmp_name'];
$handle = fopen($fileName, "r");
$valueArray = [];
while (($data = fgetcsv($handle, 1000, ","))) {
$valueArray[] = $data;
}
fclose($handle);
// print_r($valueArray);
foreach ($valueArray as $key => $value) {
mysqli_query($con, "INSERT INTO tugas (judul, durasi, id_agenda) VALUES ('$value[0]', '$value[1]', '$_GET[idagenda]')") or die(mysqli_error($con));
}
}
// echo "<script>window.location='./?page=create&idagenda=".$_GET['idagenda']."';</script>";
// echo '<meta http-equiv="refresh" content="0;url=./?page=create&idagenda='.$_GET["idagenda"].'" />';
header("location: ./?page=create&idagenda=".$_GET['idagenda']);
?>