GIF89a php
Current File : /home/hencockfreshchic/public_html/admin.cpanel/uploads/updateBlog.php
<?php
ob_start();
ini_set('error_reporting', E_STRICT);
include("connect.php");
mysqli_set_charset($conn,'utf8');
date_default_timezone_set('Asia/Kolkata');

$btitle=$_POST['btitle'];
$content=$_POST['content'];
$image=$_FILES["image"]["name"];
$sr=$_POST['sr'];

// target directory
$target_dir='blog_image/'.mt_rand(100,987).mt_rand(985,1453).trim($_FILES["image"]["name"]);

if($image==""){
//move_uploaded_file($_FILES["image"]["tmp_name"],$target_dir);
$sql="UPDATE `blog` SET `blog_img`='NA',`blog_title`='".$btitle."',`blog_desc`='".$content."',`blog_date`='".date('Y-m-d')."',`blog_time`='".date('H:i:s A')."' WHERE `sr`='".$sr."'";
$rs=mysqli_query($conn,$sql);
if($rs>0)
{
	echo '<script>alert("Blog has been updated");</script>';
 	 echo '<script>window.location.href="blogs.php";</script>';
}
else{
	 echo '<script>alert("Error : Unable to update blog. Contact to developer");</script>';
 	 echo '<script>window.location.href="blogs.php";</script>';
}
}
else
{
move_uploaded_file($_FILES["image"]["tmp_name"],$target_dir);
$sql="UPDATE `blog` SET `blog_img`='".$target_dir."',`blog_title`='".$btitle."',`blog_desc`='".$content."',`blog_date`='".date('Y-m-d')."',`blog_time`='".date('H:i:s A')."' WHERE `sr`='".$sr."'";
$rs=mysqli_query($conn,$sql);
if($rs>0)
{
	echo '<script>alert("Blog has been updated");</script>';
 	 echo '<script>window.location.href="blogs.php";</script>';
}
else{
	 echo '<script>alert("Error : Unable to update blog. Contact to developer");</script>';
 	 echo '<script>window.location.href="blogs.php";</script>';
}
}

?>