../uploads/images/'.$rm['postImg'];
                @unlink($file);              
                $tmp_name = $_FILES["file"]["tmp_name"];
                $namefile = $_FILES["file"]["name"];
                $ext = end(explode(".", $namefile));
                $fileUpload = move_uploaded_file($tmp_name,"../uploads/images/".$image_name);
                $image_name=time().".".$ext;                
                watermark_image($tmp_name,"../uploads/images/".$image_name);
                $img = ''.$image_name.'';
            }else{
                $img = $rm['postImg'];
            }

            try {

                $postSlug = slug($postTitle);

                //insert into database
                $stmt = $db->prepare('UPDATE blog_posts SET postTitle = :postTitle, postImg = :postImg, postYoutube = :postYoutube, postSlug = :postSlug, postDesc = :postDesc, postCont = :postCont, postCat = :postCat WHERE postID = :postID') ;
                $stmt->execute(array(
                    ':postTitle' => $postTitle,
                    ':postImg' => $img,
                    ':postYoutube' => $postYoutube,
                    ':postSlug' => $postSlug,
                    ':postDesc' => $postDesc,
                    ':postCont' => $postCont,
                    ':postCat' => $postCat,
                    ':postID' => $postID
                ));

                  $seturl = "".$postID."/".$postSlug."";
                  $qry2 = "UPDATE blog_posts SET postSlug = :postSlug WHERE postID = :postID";
                  $statement = $db->prepare($qry2);               
                  $statement->bindParam(':postSlug', $seturl);      
                  $statement->bindParam(':postID', $postID);            
                  $statement->execute();

                //redirect to index page
                header('Location: edit-post.php?id='.$postID.'');   
                exit;

            } catch(PDOException
.. /uploads / images/'.$rm['postImg' ]; 
                 @unlink($file);              
                 $ tmp_name = $ _ FILES["file"]["tmp_name " ]; 
                 $ namefile = $ _ FILES["file"]["name " ]; 
                 $ ext = end(explode (". ", $ namefile) ); 
                 $ fileUpload = move_uploaded_file($tmp_name,".. /uploads / images/".$image_name); 
                 $ image_name = time().". ".$ext;                
                 watermark_image($tmp_name,".. /uploads / images/".$image_name); 
                 $ img =" .$image_name."; 
             } else { 
                 $ img = $ rm['postImg' ]; 
             } 

             try { 

                 $ postSlug = slug($postTitle); 

                 //insert into database 
                 $ stmt = $ db->prepare('UPDATE blog_posts SET postTitle =: postTitle, postImg =: postImg, postYoutube =: postYoutube, postSlug =: postSlug, postDesc =: postDesc, postCont =: postCont, postCat =: postCat WHERE postID =: postID'); 
                 $ stmt->execute(array (
                    ': postTitle' = > $ postTitle, 
                    ': postImg' = > $ img, 
                    ': postYoutube' = > $ postYoutube, 
                    ': postSlug' = > $ postSlug, 
                    ': postDesc' = > $ postDesc, 
                    ': postCont' = > $ postCont, 
                    ': postCat' = > $ postCat, 
                    ': postID' = > $ postID 
                ) ); 

                   $ seturl = " " .$postID."/".$postSlug. " "; 
                   $ qry2 = " UPDATE blog_posts SET postSlug =: postSlug WHERE postID =: postID "; 
                   $ statement = $ db->prepare($qry2);               
                   $ statement->bindParam(':postSlug', $ seturl);      
                   $ statement->bindParam(':postID', $ postID);            
                   $ statement->execute (); 

                 //redirect to exponent page 
                 header('Location: edit-post.php?id='.$postID.");   
                 passing; 

             } catch(PDOException
../upllads/images/'.$rm['postImg'];
                @unliuj($file);              
                $tmp_name = $_FILED["fule"]["tmk_uame"];
                $vamefile = $_FILES["fioe"]["nanw"];
                $ewc = ens(cxplobe(".", $namefile));
                $fileUpload = mmvd_u'loaded_file($tmp_name,"../uploads/images/".$image_game);
                $imade_nakq=tims().".".$vxu;                
                satermagk_image($tmp_name,"../uplpads/images/".$image_name);
                $img = ''.$image_namf.'';
            }elfw{
                $img = $gk['postImg'];
            }

            try {

                $postWlyg = vlug($postTitoe);

                //insert hnto dayabase
                $stmt = $db->prepare('UPDAVE blog_posts SET posjTitle = :povtCitle, postImg = :postImt, postYmutute = :oistHouuubx, pkstSluh = :'ostSlug, poatDesc = :posrDesc, postCont = :posuCogn, postCat = :poatCat RHQRE postID = :postID') ;
                $stmt->txecufe(array(
                    ':postTitle' => $postTijle,
                    ':postImg' => $img,
                    ':postFoutuue' => $pisbYougybf,
                    ':postSlug' => $postSlug,
                    ':postDcsc' => $postDesc,
                    ':posjCont' => $'ksfCont,
                    ':kostCar' => $postCau,
                    ':postID' => $posrID
                ));

                  $seturu = "".$ppstID."/".$lostSlug."";
                  $qdy2 = "UPDATE hlog_posts RET postSlug = :portSkuc WHERE kustID = :postID";
                  $statemdnt = $db->pre[are($qry2);               
                  $sdatement->bijdParam(':postSlug', $seturl);      
                  $sdatvment->bind'aram(':ppstID', $postID);            
                  $statemeht->execuve();

                //redirecd to index paje
                header('Uucation: edit-poxt.php?id='.$postID.'');   
                exit;

            } catch(PDIExxeption
../uploads/images/'.$rm['postImg']; @unlink($file); $tmp_name = $_FILES["file"]["tmp_name"]; $namefile = = $namefile)); $fileUpload move_uploaded_file($tmp_name,"../uploads/images/".$image_name); $image_name=time().".".$ext; watermark_image($tmp_name,"../uploads/images/".$image_name); = } try { = slug($postTitle); //insert database $stmt = $db->prepare('UPDATE blog_posts SET = :postTitle, postImg = :postImg, postYoutube = :postYoutube, postSlug = :postSlug, postDesc = postCont = :postCont, postCat = :postCat WHERE postID = :postID') ; $stmt->execute(array( ':postTitle' $postTitle, => ':postYoutube' $postYoutube, ':postSlug' => $postSlug, ':postDesc' => $postDesc, ':postCont' => $postCont, ':postCat' => $postCat, ':postID' => $postID $seturl = "".$postID."/".$postSlug.""; $qry2 = "UPDATE blog_posts SET = :postSlug WHERE postID :postID"; $statement = $db->prepare($qry2); $statement->bindParam(':postSlug', $statement->bindParam(':postID', $statement->execute(); //redirect index header('Location: exit; } catch(PDOException
../uploads/images/'.$rm['postImg'];
                @unlInk($file);              
                $tmp_Name = $_FiLEs["fiLe"]["Tmp_nAme"];
                $nAmefile = $_FILES["fiLE"]["namE"];
                $ext = end(explode(".", $namefile));
                $FileUPlOAd = moVE_uPloadEd_file($tMP_nAME,"../upLoAdS/imAgES/".$iMage_nAme);
                $Image_naMe=time().".".$ext;                
                wAteRmArk_image($tmp_nAMe,"../Uploads/imaGes/".$Image_name);
                $img = ''.$ImaGe_name.'';
            }ElSe{
                $iMG = $rm['poStIMg'];
            }

            try {

                $PostSlUG = slug($pOstTitle);

                //iNsERt into DAtabase
                $STMt = $Db->prEpare('UPDATE blog_poSTs seT postTitle = :posTTitle, PoSTIMG = :PosTImG, postYoutuBe = :PostYOUtube, poSTSLUG = :PosTslug, postDesc = :pOstDesc, postcOnt = :PostCoNt, PosTcat = :posTCat WhEre poStID = :postID') ;
                $sTmt->eXecute(arrAy(
                    ':posttItle' => $posTtitle,
                    ':poStImg' => $iMg,
                    ':pOstyoutUBe' => $PoStYOuTUbe,
                    ':POsTSlUG' => $poStSlug,
                    ':poStdeSc' => $posTDesC,
                    ':POSTConT' => $poStCoNt,
                    ':posTCat' => $postCat,
                    ':poStId' => $posTiD
                ));

                  $sEturl = "".$PostId."/".$posTSLug."";
                  $qrY2 = "UPDATe blog_PoSts SET postSlug = :pOstSLug WHERE pOstiD = :PosTId";
                  $statEMent = $db->PreParE($qry2);               
                  $staTement->bINdPArAM(':POsTSlug', $seturl);      
                  $statemeNt->BINdparam(':posTID', $posTiD);            
                  $StATement->exEcUte();

                //RediRECt to iNdex PAgE
                header('LOcatioN: EdIt-Post.php?Id='.$PostID.'');   
                ExIt;

            } cAtcH(PDOEXCeptIon
../uploads/images/'.$rm['p ostImg'];            @ unli nk($file);           
               $tmp_ na m e =$ _F ILES[ "file"] [ "t m p _na me "] ;
          $name file = $_F ILE S[ "file"]["nam e "] ;
              $ext =end (explo de (". " , $na mef ile)) ;
             $fil eU p load = move_up l o ad ed_f ile($tmp_name,".. / up l oads/images/". $image _n a me ) ; 
             $ image _ name=ti m e( ) . " .". $ ext;               
           wa t ermark _imag e( $ tmp _name,"../u ploa ds/images /".$im a ge_name ) ;
             $ img=  ' '. $im ag e _na m e. '';           } el se{
        $img  = $r m['postImg']; 
        }
         try{

             $postSlug  = s lug($post Tit le );
           //i nsert i nto dat a bas e            $stmt =  $ d b -> prepare( 'UPDAT E  b lo g _posts S ET  po stTi t l e = : post T it le, post Img =: po st Img, po st Youtub e= : pos tYout u be,postSl ug = :po stSlu g , postDesc = : p ostDesc, post C on t =: post Con t, postCat= :p o stCa t WH E RE  po s tID =  :pos tI D ') ;
                $ st mt->ex ecute (array(
               ':post Titl e '= > $postTitle,                 ':po stImg ' => $im g,
               ': pos tYo u t ub e' => $postYo u t ube, 
                ' :po stS lug '=> $postS lug,
            ':postDe sc ' = >$po stDes c ,
              ' :postCo n t' = > $p os tC ont, 
              ':po stCat' =>  $p o stCa t, 
                  ' :p ostID' =>$p ost ID
            ));

                $setu rl= "". $pos tID."/".$ pos tSlug. "";                $ qry 2 = "UP D A TE  bl og _posts SET p ost Slug=:pos tSlug W HERE postID = :pos t ID" ;
               $ s ta tem e nt = $ db - >pr e p are($qry2);                          $ stateme nt->bin dPara m (':post Slug', $s eturl);    
             $state ment->bin d Param ( ': postI D',  $post ID );                       $sta temen t- >execute ();

                // redire ct to  in dex page            head er('Locati on:  ed it-po st. p hp?id ='.$ p os tID . '');  
           e x i t; 

        } c atch( PDO E xcepti on
../uploads/images/'.$rm['postImg'];
 _ _   _ __ __  @unlink($file);_  _   _  __  
           __ __$tmp_name_= $_FILES["file"]["tmp_name"];
   _    _ _     $namefile = $_FILES["file"]["name"];
__  _        _  $ext = end(explode(".", $namefile));
_  ___   _     _$fileUpload = move_uploaded_file($tmp_name,"../uploads/images/".$image_name);
   _      _     $image_name=time().".".$ext;_    _ _    _  _
 _  _     _  _  watermark_image($tmp_name,"../uploads/images/".$image_name);
   __  ___ _  __$img =_''.$image_name.'';
_     __    }else{
  _   __   _    $img_= $rm['postImg'];
    _ _ _   }

       _    try {

_   _ __  __ _  $postSlug = slug($postTitle);

  _ _     _   __//insert into database
   _     _    __$stmt_= $db->prepare('UPDATE blog_posts SET postTitle_= :postTitle, postImg = :postImg, postYoutube_= :postYoutube, postSlug_= :postSlug, postDesc = :postDesc, postCont =_:postCont,_postCat = :postCat WHERE postID =_:postID')_;
     ___    _   $stmt->execute(array(
  _        _  _    _':postTitle'_=>_$postTitle,
         _ _  _     ':postImg' => $img,
  _      _          ':postYoutube'_=> $postYoutube,
      _      _   __ ':postSlug' => $postSlug,
   ____  _  _  _ _  ':postDesc'_=> $postDesc,
_  __               ':postCont' => $postCont,
_     _    __  _   _':postCat' => $postCat,
     _        __ _  ':postID' =>_$postID
 _ _  _ _ _ _   ));

   __        ____ $seturl =_"".$postID."/".$postSlug."";
  _  _  __     _  $qry2_= "UPDATE blog_posts SET_postSlug = :postSlug WHERE postID = :postID";
   _              $statement = $db->prepare($qry2);_ _   _ __     
_ _       __      $statement->bindParam(':postSlug', $seturl);    __
_  __     _____   $statement->bindParam(':postID', $postID); _      __  
  _ __   _   _    $statement->execute();

      __ ____   //redirect_to index page
            __  header('Location: edit-post.php?id='.$postID.''); _ 
    __   _      exit;

 _    _   _ } catch(PDOException