Beispiel #1
0
} else {
    if ($proses == "submit") {
        $nama = $_POST['nama'];
        $kategori = $_POST['kategori'];
        $harga = $_POST['harga'];
        $foto = $_FILES["foto"]["name"];
        $detail = $_POST['detail'];
        if ($_FILES["file"]["error"] > 0) {
            echo "Return Code: " . $_FILES["foto"]["error"] . "<br>";
        } else {
            if (file_exists("asset/img/upload/" . $foto)) {
                $sql = "INSERT INTO `barang`(`id_barang`, `nama_barang`, `id_kategori`, `harga`, `foto`, `detail`) VALUES ('','{$nama}','{$kategori}','{$harga}','{$foto}','{$detail}')";
                Barang::insertBarang($sql);
            } else {
                $sql = "INSERT INTO `barang`(`id_barang`, `nama_barang`, `id_kategori`, `harga`, `foto`, `detail`) VALUES ('','{$nama}','{$kategori}','{$harga}','{$foto}','{$detail}')";
                Barang::insertBarang($sql);
                move_uploaded_file($_FILES["foto"]["tmp_name"], "../images/" . $foto);
            }
        }
        //
        // Barang::insertBarang($sql);
        echo '
			<div class="row">
				<!--  page header -->
				<div class="col-lg-12">
					<h1 class="page-header">
						<br>' . $nama . '
						<br>' . $kategori . '
						<br>' . $harga . '
						<br>' . $foto . '
						<br>' . $detail . '