prepare( "INSERT INTO image_gallery (title, image) VALUES ('".$_POST['title']."', '".$image_name."')"); //$mysqli->query($sql); $sql->execute() ; $_SESSION['success'] = 'Image Uploaded successfully.'; header("Location: gallery.php"); }else{ $_SESSION['error'] = 'image uploading failed'; header("Location: gallery.php"); } }else{ $_SESSION['error'] = 'Please Select Image or Write title'; header("Location: gallery.php"); } ?>