lundi 30 août 2021

the if requirement is simply skipped through in php [duplicate]

<script>
if (confirm("Are you sure you want to save this thing into the database?")) { 
  var jvalue = "LEVELISGOINGUP!";
  alert(jvalue);
} else {  
  var jvalue = "null";
  alert(jvalue);
}
</script>

<?php 
  $valueofjs = "" . "<script>document.writeln(jvalue)</script>";
  if($valueofjs == "LEVELISGOINGUP!"){
    echo 'it's work!';
  }
?>

I'm using a JS var for an if condition. the var name is jvalue and I convert it to PHP var $valueofjs.

I already trying to post the $valueofjs value by echo and it's working fine.

but when I'm using it as for if the condition it didn't work. it just passes through like the condition wasn't met.

Please help! Thank you.

Aucun commentaire:

Enregistrer un commentaire