<?php session_start();
    if (isset($_SESSION['logged']) && $_SESSION['logged'] == 'yes') {
        //Prevent accessing the page withou POST METHOD
        if($_SERVER['REQUEST_METHOD'] != 'POST') exit('This page cannot be accessed directly');
        include ('../../../scripts/classes.php');
        if ($_SESSION['lang']=="EN"){$lang="EN"; include ('../../../lang/en.php');}elseif ($_SESSION['lang']=="GR"){$lang="GR";include ('../../../lang/gr.php');}else {$lang="EN";include ('../../../en.php');}
        $logged_user = $_SESSION['user'];
            //get post values and sanitize
            $delivery_name = mysqli_real_escape_string($mysqli, $_POST['delivery_name']);
            $campaign_id = mysqli_real_escape_string($mysqli, $_POST['campaign']);
            $sender_id = mysqli_real_escape_string($mysqli, $_POST['sender']);
            $sms_text = mysqli_real_escape_string($mysqli, $_POST['sms_text']);
            $time_set = mysqli_real_escape_string($mysqli, $_POST['exec_time']);
            $is_active = isset($_POST['is_active']) ? mysqli_real_escape_string($mysqli, $_POST['is_active']) : '';  
                                    
            $sql_save = ("INSERT INTO ".TABLE_SMS_AUTO_SETUP."  
                        (id, campaign_id, description, time_set, sms_text,  sender_id, created_on, created_by, updated_on, updated_by, is_active) 
                        VALUES (NULL, '".$campaign_id."', '".$delivery_name."', '".$time_set."', '".$sms_text."', '".$sender_id."', NOW(), '".$logged_user."', NULL, '', '".$is_active."')");
            $result_save = database_void_query($mysqli, $sql_save, false) or die ('An error occured while trying to save the record');
} else {
    header('Location: login.php');
}
?>

