<?php

include "classes/html.class.php";

$html = new html("EVENTS");


$db = new db();



?>



<div class='form'>
    <h2 style="font-size:2vw">ADD LOG REASON:</h2>
    <hr><br>
    <label style="font-size:1.5vw">REASON NAME:</label><br>
    <input type='text' placeholder="NAME" id='name' class='form_input' /><br><br>
    <input type='submit' value='ADD' class='form_btn' onclick='ajax_func()' />

</div>

<script>
    function ajax_func() {
        // alert("Test");
        name = document.getElementById('name').value;

        // Create an XMLHttpRequest object
        const xhttp = new XMLHttpRequest();
        // Define a callback function
        xhttp.onload = function() {
            // Here you can use the Data
            if (this.responseText != 1) {

                alert(this.responseText);

            } else {
                alert('ADDED');
                window.location.href = "reasons.php";
            }
        }

        xhttp.open("GET", "ajax/add_log_reason.ajax.php?&name=" + name);
        xhttp.send();

    }
</script>


</body>

</html>