-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertProses.php
More file actions
33 lines (27 loc) · 964 Bytes
/
insertProses.php
File metadata and controls
33 lines (27 loc) · 964 Bytes
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
<?php
include "koneksi.php";
$target_path = "uploads/";
$nomor = $_POST['id'];
$nama = $_POST['nama'];
$harga = $_POST['harga'];
if(!file_exists($target_path)) {
mkdir($target_path, 0755, true);
echo "The directory was created ";
}
$target_path = $target_path . basename(
$_FILES['poto']['name']);
$tmp_name = $_FILES['poto']['tmp_name'];
$sql = "insert into product values
('$nomor', '$nama', '$harga', '$target_path')";
if (mysqli_query($connect, $sql)) {
if (move_uploaded_file($_FILES['poto']['tmp_name'], $target_path)) {
echo "The file " . basename($_FILES['poto']['name'] . " has been uploaded<br>");
}else{
echo "There was an error uploading the file, please try again";
}
echo "Data berhasil ditambahkan";
} else {
echo "Data gagal ditambahkan <br>" . mysqli_error($connect);
}
mysqli_close($connect);
?>