Save Javascript variable in PHP

2

I have a variable in JavaScript that I can send to value of a form in html.
The input where the variable is loaded is like hidden because I do not want it to display the value on the screen. The form only has that input and a button to send the form by method POST to a PHP file where I want it to store the variable.
The point is that he does not ...

I do not know what I'm missing or what I'm doing wrong. I put the code here.

JavaScript file

document.getElementById("puntos").setAttribute("value",highscore);

I use this to send the value of the form input and it works.

HTML file

<form action="rank_insert.php" method="post">
    <input id="puntos" name="puntos" type="hidden" value="" />
    <input type="submit" name="submit" value="Guardar" />   
</form>

PHP file

<?    
$puntos = $POST['puntos'];

echo "Puntos: ".$puntos;
?>

And here is where only the text "Points:" appears and nothing more ... It's as if the variable was not passed.

    
asked by Jok 22.10.2018 в 20:20
source

1 answer

4

The problem is that you try to access the variable $POST to see the data of the form when in fact the name of the variable is $_POST . link

    
answered by 22.10.2018 / 20:33
source