I have made a simple php cms form with database but it does not work properly when I want to submit the form with some dummy data! I don\'t know why it happens & also I adde
Changes
empty
for check empty variable||
instead of or
move_uploaded_file
)$post_image'
) - This is the bug in your codemysqli_error
(if (!$insert_post){
)Code
alert("Some fields are missing")';
}
else
{
if (!move_uploaded_file($image_tmp,"post_images/$post_image")) {
echo "Move Failed";
}
else
{
$insert_query = "INSERT INTO posts (post_title,post_date,post_author,post_image,post_keywords,post_content) VALUES ('$post_title','$post_date','$post_author','$post_image','$post_keywords','$post_content')";
$insert_post = mysqli_query($con,$insert_query);
if (!$insert_post){
echo mysqli_error($con);
}
else
{
echo 'Post has been added successfully.
';
}
}
}
}
?>