Tahun baru, skill baru! 🚀. Masukkan kupon "skill2025" untuk diskon 30% di kelas apa saja

Cara update data dan gambar dengan php pdo

ini alert nya berhasil tapi waktu di cek di database posgresql tidak ter-update mohon pencerahannyaa

<?php

session_start();
require 'koneksi.php';

$setPost = array(
	":id" => $_POST['id']
);

$query = $db->prepare("SELECT id, email, username, password, pict FROM public.tb_user WHERE id = :id ;");
$query->execute($setPost);
$dataAwal = $query->fetch(PDO::FETCH_ASSOC);

$email = $_POST["email"];
$file = $_FILES["pict"];
$username = $_POST["username"];
$password = $_POST["password"];

if ( empty($file["name"]) != true ) {

	$filetype = explode("/", $file["type"]);

	$fileLocation = "files/" .date("YmdHis") . "." . $filetype[1];

	$upload = move_uploaded_file($file["tmp_name"], $fileLocation);
}
else{
	$fileLocation = $dataAwal['pict'];
}

if ( $upload == true || $fileLocation == $dataAwal['pict'] ) {
	$setPost = array (
		":id"	=> $_POST['id'],
		":email"	=> $email,
		":pict"	=> $fileLocation,
		":username"	=> $username,
		":password"	=> $password,
);

$query = $db->prepare("UPDATE tb_user SET email = :email, pict = :pict, username =:username, password = :password WHERE id = :id;");

$query->execute($setPost);

echo "<script>
	alert('Berhasil!');
	document.location='drive.php';
	</script>";
}
else {
	echo "<script>
		alert('Upload Gagal!');
		document.location='drive.php';
		</script>";
}
?>

avatar oceanli
@oceanli

63 Kontribusi 2 Poin

Dipost 6 tahun yang lalu

Tanggapan

halo mas/mba coba bertanya lebih jelas. Kamu bikin apa, apa masalahnya. Tampilkan bagian kode yang relevan saja. Saya bingung dengan pertanyannya

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban