dimanche 22 juillet 2018

How can I use PHP $_SESSION in javascript function?

Okay, here are something I have now.

I'd like to use $_SESSION['pass'] in my other php files to make it as a condition to check whether an if condition is true. But it seems that the system only shows the alert part and never runs the code in the PHP tag. Thanks a lot!

document.getElementById('pass').onclick = function(){
    <?php $_SESSION['pass']=1; ?>
    alert('here!');
}
document.getElementById('fail').onclick = function(){
    <?php $_SESSION['pass']=0; ?>
    alert('there!');
}




Aucun commentaire:

Enregistrer un commentaire