I have a problem calling the postRefreshPage () function on a button that means you should go back to the menu page and send the user's data so that the session stays started.
This is the button:
<button class="btn btn-warning btn-sm" aria-label="Right Align" style="float: right;" onclick="postRefreshPage();">
<span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span>
Regresar al menu
</button>
And this is the function:
function postRefreshPage(){
var theForm, newInput1, newInput2;
// Se crea el <form>
theForm = document.createElement('form');
theForm.action = 'pruebas/checklogin.php';
theForm.method = 'post';
// Se crean los <input>s en el form y les damos nombre y valor
newInput1 = document.createElement('input');
newInput1.type = 'hidden';
newInput1.name = 'username';
newInput1.value = "<?php echo $_SESSION['user']?>";
newInput2 = document.createElement('input');
newInput2.type = 'hidden';
newInput2.name = 'password';
newInput2.value = "<?php echo $_SESSION['pass']?>";
// Lo juntamos todo...
theForm.appendChild(newInput1);
theForm.appendChild(newInput2);
// ...y ahora al DOM...
document.getElementById('hidden_form_container').appendChild(theForm);
// ...y lo mandamos
theForm.submit();
}
And he throws me this error:
Uncaught ReferenceError: postRefreshPage is not defined
at HTMLButtonElement.onclick
This page is on a server and it is where I get the error, but when I ran it in the local everything worked fine.
Thank you in advance for your answers