<?php include('../../config/setup.php');?>

<?php
if(isset($_POST['Lee_about_img_edit'])){
	$id = $_POST['Edit_about_id'];
    // aboutus image
        $images = $_FILES['about_image']['name'];
        $old_filename = $_POST['old_about_image'];
        $update_filename = "";
        if($images != NULL){
            $image_extension = pathinfo($images,PATHINFO_EXTENSION);
            $filename = time().'.'.$image_extension;
            $update_filename = $filename;
        }else{
            $update_filename = $old_filename;
        }
    $imageediton=date('Y-m-d'); 
    $sql="UPDATE cms SET About_us_img ='$update_filename' where cms_id= '$id' ";
    $update_about_photo=mysqli_query($config,$sql);
    if($update_about_photo==false)
    {
        echo  "<script>window.location.href='../about_us.php?erro=0';</script>".mysqli_error($update_abot);	 
    }
    else{
         if($images != NULL){
                if(file_exists('../../../assets/img/about/'.$old_filename)){
                    unlink('../../../assets/img/about/'.$old_filename);
                }
                move_uploaded_file($_FILES['about_image']['tmp_name'],'../../../assets/img/about/'.$update_filename);
            }
        echo  "<script>window.location.href='../about_us.php?mes=0';</script>";	   
    }
}


    if(isset($_POST['Lee_about_edit'])){ 
        $sql = "update cms set About_us='".$_POST['about_title']."' , About_us_desc='".$_POST['about_desc']."' where cms_id='".$_POST['Edit_about_cms_id']."'"; 
        $update_about=mysqli_query($config,$sql);
        if($update_about==false) {
            echo  "<script>window.location.href='../about_us.php?erro=0';</script>".mysqli_error($update_abot);	 
        }else{
            echo  "<script>window.location.href='../about_us.php?mes=0';</script>";	 	
        }
    }
?>


<?php
    if(isset($_POST['pro_img_edit'])){
	$id = $_POST['Edit_pro_id'];
    $proimage = $_FILES['pro_image']['name'];
    $prophoto="../../../img/pro/".$proimage;
    move_uploaded_file($_FILES["pro_image"]["tmp_name"],$prophoto);
    $imageediton=date('Y-m-d'); 
    $sql="UPDATE cms SET pro_img ='$proimage' where cms_id= '$id' ";

    $update_pro_photo=mysqli_query($config,$sql);
    if($update_pro_photo==false)
    {
        echo  "<script>window.location.href='../adproducts.php?erro=0';</script>".mysqli_error($update_abot);	 
    }
    else{
        echo  "<script>window.location.href='../adproducts.php?mes=0';</script>";	   
    }

    }


    if(isset($_POST['pro_edit'])){ 

    $sql = "UPDATE cms SET pro_title='".$_POST['pro_title']."' , pro_desc='".$_POST['pro_desc']."' where cms_id='".$_POST['Edit_pro_cms_id']."'";
    
    $update_pro=mysqli_query($config,$sql);
        if($update_pro==false){
            echo  "<script>window.location.href='../adproducts.php?erro=0';</script>".mysqli_error($updatepro);	 
        }else{   
            echo  "<script>window.location.href='../adproducts.php?mes=0';</script>";	    
        }
    }


 ?>