
<?php
   // session_start();
    include_once('../config/conn/db-connection.php');
    include_once('../config/class/sap_model.php');
    $SAP = new SAP_infosytem();

        if(ISSET($_POST)){

               $first_name = trim($_POST['first_name']);
               $last_name = trim($_POST['last_name']);
               $name = ucfirst($last_name) .', '.ucfirst($first_name);

               $email = trim($_POST['email']);
               $contact_number = trim($_POST['contact_number']);
               $message = trim($_POST['message']);

              // ==========audit trail==================
               $user =  $name;
               if(!empty($_SERVER["HTTP_CLIENT_IP"])){
                     $ip = $_SERVER["HTTP_CLIENT_IP"];
                  }elseif(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){ 
                     $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
                  }else{
                     $ip = $_SERVER["REMOTE_ADDR"];
                }
               $host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
               date_default_timezone_set("asia/manila");
               $logdate =  date('M-d-Y h:i A', strtotime("+0 HOURS"));
               $action = "'Member' added a comment to Contact Us whose name is ".$name;    
            // ==========end audit trail==============


               $SAP->add_contact2($first_name, $last_name, $email, $contact_number, $message, $user, $ip, $host,  $logdate, $action);
                  echo '<script type="text/javascript">';
                  echo 'setTimeout(function () { swal("Add Contact Successfully!","Message!","success");';
                  echo '}, 1000);</script>';
                  echo '<script type="text/javascript">';
                  echo 'setTimeout(function(){';
                  echo 'window.location = "/SAP_Information_System/Members/contact.php"';
                  echo '},1000)';
                  echo '</script>';
             
        }
?>