<?php

$db1 = new SQLite3("./api/db/slc_message.db");
if (isset($_POST["submit"])) {
    $db1->exec("INSERT INTO messages(message, userid, status, expire) VALUES('" . $_POST["message"] . "', '" . $_POST["userid"] . "', '" . $_POST["status"] . "', '" . $_POST["expire"] . "')");
    header("Location: message_send.php");
}
include "includes/header.php";
echo " <!-- Begin Page Content -->\n        <div class=\"container-fluid\">\n\n";
if (isset($_GET["message"])) {
    echo $_GET["message"];
}
echo "          <!-- Content Row -->\n          <div class=\"row\">\n\n            <!-- First Column -->\n            <div class=\"col-lg-12\">\n\n              <!-- Custom codes -->\n                <div class=\"card text-text-primary\">\n                <div class=\"card-header bg-primary py-3\">\n                <center><h4 align=\"center\" class=\"m-0 text-white\"><i class=\"fa fa-comment\"\n                                    style=\"font-size:20px\">&nbsp;&nbsp;</i> Create Message</h4>\n                        \n\t\t\t\t\t\t</center>\n\n            </div>\n                <div class=\"card-body\">\n                            <form method=\"post\">\n\t\t\t\t\t\t\t<div class=\"form-group \">\n                            <label class=\" text-primary control-label\" for=\"apkautoupdate\" >\n                              <strong>  Message: </strong>\n                                    </label>\n                                    <div class=\"input-group\">\n                                        <input class=\"form-control text-primary\" id=\"description\" name=\"message\" placeholder=\"Message\" value='' type=\"text\"/>\n                                    </div>\n\n                                </div>\n                                <div class=\"form-group \">\n                                    <label class=\" text-primary control-label \" for=\"userid\">\n                                        <strong>Username</strong> \n                                    </label>\n                                    <div class=\"input-group\">\n                                        <input class=\"form-control text-primary\" id=\"description\" name=\"userid\" placeholder=\"Username\" value='' type=\"text\"/>\n                                    </div>\n\n                                </div>\n                                <div class=\"form-group \">\n                                    <label class=\"control-label text-primary requiredField\" for=\"status\" >\n                                        <strong>Status</strong>\n                                    </label>\n                                    <select class=\"select form-control text-primary\" id=\"select\" name=\"status\">\n                                        <option value=\"ACTIVE\">\n                                            ACTIVE\n                                        </option>\n                                        <option value=\"INACTIVE\">\n                                            INACTIVE\n                                        </option>\n                                    </select>\n\n                                </div>\n                                <div class=\"form-group \">\n                                    <label class=\"control-label text-primary \" for=\"message\">\n                                        <strong>Expire</strong>\n                                    </label>\n                                    <div class=\"input-group\">\n                                        <input type=\"text\" class=\"form-control text-primary text-primary\" name=\"expire\" placeholder=\"YYYY-MM-DD\" id=\"datetimepicker\"  autocomplete=\"off\"> \n                                    </div>\n\n                                </div>\n                                <div class=\"form-group\">\n                                    <div>\n                                        <button class=\"btn btn-success btn-icon-split\" name=\"submit\" type=\"submit\">\n                        <span class=\"icon text-white-50\"><i class=\"fas fa-check\"></i></span><span class=\"text\">Submit</span>\n                        </button>\n                                    </div>\n\n                                </div>\n                            </form>\n                        </div>\n                    </div>\n                </div>\n\n        </div>\n    </div>\n    <br><br><br>";
include "includes/footer.php";
require "includes/slc.php";
echo "      </body>\n";

?>