<?php
include('connection.php');
$conn = mysqli_connect("localhost","aradhayasafetynets","Kmk[I4#Wz;*#","aradhayasafetynets");
if (isset($_POST['submit'])) {



	$heading = $_POST['heading'];
	$message = $_POST['message'];
	$image = $_FILES['image']['name'];  
	if (file_exists("uploads/".$_FILES["image"]["name"])) {
		$store = $_FILES["image"]["name"];
		$_SESSION['status'] = "image already exits. '.$store.'";
		header('Location: index.php');
	}else{
		$query = "INSERT INTO `blog`(`image`, `heading`, `message`) VALUES ('$image','$heading','$message')";
		$query_run = mysqli_query($conn,$query);

	}
	if ($query_run) {

		$filename = $_FILES["image"]["name"];
        $tempname = $_FILES["image"]["tmp_name"];
        $folder = "uploads/".$filename;
        echo $folder;
        move_uploaded_file($tempname, $folder);

	}
	header("Location:blog.php");

}

?>