<?php

include "classes/html.class.php";

$html = new html("LOG REASONS");
?>



<div class='form'>
    <h2 style="font-size:2vw">ADD REASON:</h2>
    <hr><br>
    <input type='text' placeholder="FARM NAME" id='farm_name' class='form_input' /><br><br>

    <input type='submit' value='ADD' class='form_btn' onclick='ajax_func()' />

</div>

<script>
    function ajax_func() {
        // alert("Test");
        farm_name = document.getElementById('farm_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 {
                window.location.href = "farms.php";
            }
        }

        xhttp.open("GET", "ajax/add_farm.ajax.php?farm_name=" + farm_name);
        xhttp.send();

    }
</script>


</body>

</html>