<?php session_start();
require_once("../../config/config.php");
//require_once("../config/commonsetting.php");

$myformId=SESS_MASTER;
$myIp= ipCheck() ;
$dateceated=date("Y-m-d G:i:s");
$createdby='0';

$title=   $_REQUEST[SESS_MASTER.'title'];
$description	=$_REQUEST[SESS_MASTER.'description'];
$keyword=   $_REQUEST[SESS_MASTER.'keyword'];
$editor	=  $_REQUEST['editor1'];
$page=   $_REQUEST[SESS_MASTER.'page'];
    
  $sql = "SELECT * FROM page_master WHERE page_name='$page'";
   
    $myquery=$conn->query($sql);
  $mydara= $myquery->fetchAll()  ;
  
  $rows_found = $myquery->rowCount();
   


    if($_POST){
  try{
     if($rows_found=='0'){

      $olgaquerys="INSERT INTO page_master SET createdIp='$myIp',datecreated='$dateceated',short_title='$title',description='$description',
      keyword='$keyword',data='$editor',page_name='$page'"; 
    $stmts = $conn->prepare($olgaquerys);
    if($stmts->execute()){

      $_SESSION["edit_status"] = '34' ;
      
       header("location:../edit-delete-master.php?page=$page");

      }
     }else{
          $olgaquerys="UPDATE page_master SET createdIp='$myIp',datecreated='$dateceated',short_title='$title',description='$description',
      keyword='$keyword',data='$editor' WHERE page_name='$page'"; 
    $stmts = $conn->prepare($olgaquerys);
    if($stmts->execute()){

      $_SESSION["edit_status"] = '34' ;
      
         header("location:../edit-delete-master.php?page=$page");
    }
     }
 
   }
         
        // show error
        catch(PDOException $exception){
            die('ERROR: ' . $exception->getMessage());
        }
    }
  	     


 


?>