<?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';

$social_url_1=   $_REQUEST[SESS_MASTER.'social_url_1'];
$social_url_2	=$_REQUEST[SESS_MASTER.'social_url_2'];
$social_url_3=   $_REQUEST[SESS_MASTER.'social_url_3'];
$social_url_4	=  $_REQUEST[SESS_MASTER.'social_url_4'];
$social_1=   $_REQUEST[SESS_MASTER.'social_1'];
$social_2 =$_REQUEST[SESS_MASTER.'social_2'];
$social_3=   $_REQUEST[SESS_MASTER.'social_3'];
$social_4 =  $_REQUEST[SESS_MASTER.'social_4'];


    
  $sql = "SELECT * FROM social_media";
   
    $myquery=$conn->query($sql);
  $mydara= $myquery->fetchAll()  ;
  
  $rows_found = $myquery->rowCount();
   


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

      $olgaquerys="INSERT INTO social_media SET createdIp='$myIp',datecreated='$dateceated',social_url_1='$social_url_1',social_url_2='$social_url_2',
      social_url_3='$social_url_3',social_url_4='$social_url_4',social_1='$social_1',social_2='$social_2',
      social_3='$social_3',social_4='$social_4'"; 
    $stmts = $conn->prepare($olgaquerys);
    if($stmts->execute()){

      $_SESSION["social_status"] = '34' ;
      
       header("location:../social-media.php");

      }
     }else{
          $olgaquerys="UPDATE social_media SET createdIp='$myIp',datecreated='$dateceated',social_url_1='$social_url_1',social_url_2='$social_url_2',
      social_url_3='$social_url_3',social_url_4='$social_url_4',social_1='$social_1',social_2='$social_2',
      social_3='$social_3',social_4='$social_4'"; 
    $stmts = $conn->prepare($olgaquerys);
    if($stmts->execute()){

      $_SESSION["social_status"] = '34' ;
      
         header("location:../social-media.php");
    }
     }
 
   }
         
        // show error
        catch(PDOException $exception){
            die('ERROR: ' . $exception->getMessage());
        }
    }
  	     


 


?>