<?php
session_start();
include "lib/dbcon.php";

$author = mysqli_real_escape_string($con,$_POST['author']);

$title = mysqli_real_escape_string($con,$_POST['title']);
$content = $_POST['description'];
$filename=$_FILES['image']['name'];
$tempname=$_FILES['image']['tmp_name'];
$file="upload/" .$filename;
// print_r($file);
move_uploaded_file($tempname,$file);

$sub_data = "insert into blog(author,title,image,description) values ('$author','$title','$file','$content')";
 if (mysqli_query($con,$sub_data)) {
	$_SESSION['msg_scs'] = 'Data Inserted...';
	header("location: blog.php");
} 
else {
	$_SESSION['msg_err'] = 'Something Went Wrong Try Later..';
	header("location: blog.php");
}

?>