I am trying to make a confirm box which will desire which php code will be executed. Heres my code:
<script type="text/javascript">
var answer = confirm('Are you sure?');
if(answer==true)
{
<?php $confirmation = 1; ?>
}
else
{
<?php define("CONFIRMATION", 1, true); ?>
}
alert('<?php echo $confirmation; ?>')
alert('<?php echo defined("CONFIRMATION"); ?>')
</script>
The problem is , even if i click YES, $confirmation and boolean from defined() function returns 1. Whatever I click, (cancel or ok) one of them should be 0 (I've already declared $confirmation before) But both of codes at if and else blocks are used! Normally it works like this