I host the web that I created on 000webhost.com. All went well. But there are mistakes that happen sometimes. When uploading photos, adding data to the database, or when editing data. Sometimes data is stored and changed, sometimes nothing happens. Sometimes photos uploaded, sometimes nothing happens. Sometimes the data is successfully edited, sometimes nothing happens. Why is that? What is wrong?
this is my code
<?php
include('connect.php');
date_default_timezone_set('Asia/Jakarta');
$q = mysql_query("SELECT * FROM artikel");
$id = $_GET['id'];
$fileName = $_FILES['file']['name'];
$judul = $_POST['judul'];
$isi = $_POST['isi'];
$link = $_POST['link'];
$tanggal = date("Y-m-d H:i:s");
$message = "Data tidak boleh kosong!";
//Jika form nama tidak di isi
if(empty($judul || $isi || $link)){
echo "<script type='text/javascript'>alert('$message');</script>";
echo "<script>window.location = 'edit-artikel.php?id=$id';</script>";
}
//Jika kedua form di isi masukan data baru ke database
else{
$move = move_uploaded_file($_FILES['file']['tmp_name'],"img/ArtPic/{$_FILES['file']['name']}");
if ($move){
$sql = mysql_query("UPDATE `artikel` SET waktu='$tanggal', judul='$judul', isi='$isi', foto='$fileName', link='$link' WHERE id='$id'");
//Pemrosesan telah selesai, dan kembalikan ke halaman index.php
echo "<script>window.location = 'beranda-admin.php';</script>";
}elseif (empty($fileName)) {
$sql = mysql_query("UPDATE `artikel` SET waktu='$tanggal', judul='$judul', isi='$isi', link='$link' WHERE id='$id'");
echo "<script>window.location = 'beranda-admin.php';</script>";
}else{
echo "gagal bor";
}
}
exit;
?>