<?php

include "classes/html.class.php";

$html = new html("silo");
?>



    <div class='form'>
        <h2 style="font-size:2vw">ADD SILO:</h2>
        <hr>
        <h2 style="font-size:1.5vw">NAME:</h2>

        <input type='text' placeholder="SILO NAME" id='name' class='form_input' /><br><br>
        
        <h2 style="font-size:1.5vw">TONS:</h2>
        <input type='text' placeholder="TONS" id='tons' 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;
            tons = document.getElementById('tons').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("SILO ADDED");
                    window.location.href = "add_home.php";
                }
            }

            xhttp.open("GET", "ajax/add_silo.ajax.php?name=" + name + "&tons=" + tons);
            xhttp.send();

        }
    </script>


</body>

</html>