Get HTML input value and pass to variable in PHP

0

I have this input:

    <p>Início do período:</p> <input type="text" id="calendario">

    <script>
    var start = new Date(1997, 12, 01);
    var end = new Date(1998, 11, 31) ;

    $(document).ready(function() {
        $('#calendario').datepicker({
           startDate: start,
           endDate: end
        });
    });
</script>

I need the value that the user will select, how could I put this value in a php variable?

    
asked by anonymous 11.12.2017 / 16:49

1 answer

0
<input type="text" id="calendario" name="calendario">

Add a name to your field in the php you can get via $ _POST or $ _GET depends on the method that will send to the serivodor

<?php
if(isset($_POST['calendario'])){
    $calendario = $_POST['calendario'];
}
?>

Your form should look like this

<form method="post" action="urlp do seu site">
    <input type="text" id="calendario" name="calendario">
    <input type="submit" value="enviar">
</form>
    
11.12.2017 / 17:12