<?php
    session_start();
    include("../scripts/connection.php");
    include("../scripts/functions.php");
    $user_data = check_login($con);

    if($_SERVER['REQUEST_METHOD'] == "POST") {
        write_station($con, $_POST['station_name'], $_POST['station_pos']);
        header("Location: stationen.php");
        die;
    }

    include("header_footer/header.php");
?>

<body>
    <div class="center">
        <div class="headline">
            <h2>Station hinzufügen</h2>
        </div>
        <div class="form_div">
            <form method="post">
                <div class="txt_field">
                    <input id="station_name" type="text" name="station_name" required/>
                    <span></span>
                    <label for="station_name">Name</label>
                </div>
                <div class="txt_field">
                    <input id="station_pos" type="text" name="station_pos" required/>
                    <span></span>
                    <label for="station_pos">Standort</label>
                </div>
                <input id="button" type="submit" value="Hinzufügen" class="btn-confirm"/>
            </form>
        </div>
    </div>
</body>
<?php
    $con = null;
    echo file_get_contents("header_footer/footer.html");
?>