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

$title=$_POST['title'];
$type=$_POST['type'];
$uname=$_POST['uname'];
$mobb=$_POST['mobb'];
$email=$_POST['email'];
$des=$_POST['des'];
$srr=$_POST['srr'];

if($_FILES["image"]["name"]=="")
{
			
			$sql="UPDATE `savePack` SET `title`='".$title."',`type`='".$type."',`uname`='".$uname."',`mobb`='".$mobb."',`email`='".$email."',`descc`='".$des."',`datee`='".date('Y-m-d')."',`timee`='".date('h:i:s A')."' WHERE `sr`='".$srr."'";
			$rs=mysqli_query($conn,$sql);
			if($rs>0)
			{
				echo '<script>window.location.href="packs.php";</script>';
			}
			else
			{
				echo '<script>alert("Unable to update package");</script>';
	 			echo '<script>window.location.href="packs.php";</script>';
	 			
			}
}
else
{
	$temp = explode(".",$_FILES["image"]["name"]);
	$target_dir='images/'.date('Ymdhis').'.'.end($temp);

	if (file_exists($target_dir)) {
	   echo '<script>alert("Image already exist | try another file");</script>';
	   echo '<script>window.location.href="packs.php";</script>';
	}
	else
	{
		$FileType = strtolower(pathinfo($target_dir,PATHINFO_EXTENSION));
		if($FileType != "png" && $FileType != "jpg" && $FileType != "jpeg" && $FileType != "gif")
		{
		// file format not supportedonly images allows
		 echo '<script>alert("Invalid image format");</script>';
	 	echo '<script>window.location.href="packs.php";</script>';
		
		}
		else
		{
			move_uploaded_file($_FILES["image"]["tmp_name"],$target_dir);			
			$sql="UPDATE `savePack` SET `title`='".$title."',`type`='".$type."',`uname`='".$uname."',`mobb`='".$mobb."',`email`='".$email."',`descc`='".$des."',`pack_img`='".$target_dir."',`datee`='".date('Y-m-d')."',`timee`='".date('h:i:s A')."' WHERE `sr`='".$srr."'";
			$rs=mysqli_query($conn,$sql);
			if($rs>0)
			{
				echo '<script>window.location.href="packs.php";</script>';
			}
			else
			{
				echo '<script>alert("Unable to update package");</script>';
	 			echo '<script>window.location.href="packs.php";</script>';
			}
		}
	}

}
	

?>