GIF89a php
Current File : /home/hencockfreshchic/public_html/admin.cpanel/uploads/addBanners.php
<?php
ob_start();
ini_set('error_reporting', E_STRICT);
include("connect.php");

$banner_cat=$_POST['banner_cat'];
$banner_link=$_POST['banner_link'];
$title=$_POST['title'];
$desc=$_POST['desc'];
$offers=$_POST['offers'];


// target directory
$target_dir="prod_image/".mt_rand(100,1000).mt_rand(231,9475).trim($_FILES["image"]["name"]);
//$url="prod_image/".trim($_FILES["image"]["name"]);
//unlike($target_dir);

// Check if file already exists
if (file_exists($target_dir)) {
   echo '<script>alert("Image already exist | try another file");</script>';
   echo '<script>window.location.href="addbanner.php";</script>';
}
else
{
	$FileType = strtolower(pathinfo($target_dir,PATHINFO_EXTENSION));
	if($FileType != "png" && $FileType != "jpg" && $FileType != "jpeg" )
{
	// file format not supportedonly images allows
	 echo '<script>alert("Invalid image format");</script>';
 	echo '<script>window.location.href="addbanner.php";</script>';
	
}
else
{
move_uploaded_file($_FILES["image"]["tmp_name"],$target_dir);
	//runQuery($cat,$subcat,$pname,$qty,$rprice,$sprice,$pcode,$mff,$desc,$url);
$sql="INSERT INTO `banner_images`(`banner_name`, `banner_cat`, `banner_image`,`title`,`banner_desc`,`offer_title`) VALUES ('".$banner_cat."','".$banner_link."','".$target_dir."','".$title."','".$desc."','".$offers."')";
$rs=mysqli_query($conn,$sql);

if($rs>0)
{
	 echo '<script>alert("Banner live on website successfully");</script>';
     echo '<script>window.location.href="addbanner.php";</script>';
	// header("Location: cardMe.php?uid=".$uid."");
}
else
{
		 echo '<script>alert("Unable to save banner");</script>';
		echo '<script>window.location.href="addbanner.php";</script>';
}


}
}
?>