2023-05-22

Why does my PHP function only decrement my button on the first click?

When I click on my button it removes 1 from $decr but if I click again it does not remove anything:

        <?php

function myFunction() {
    global $decr;
    $decr--;
}

if (isset($_GET['name']) && $_GET['name'] === 'true') {
    $decr--;
    $_GET['name'] = 'false';
}

?>

<a href='test.php?name=true' class="button-56"><?php echo $decr; ?></a>

I made a button I made my php function to decrement 1 but when I click a second time it does not remove anything.



No comments:

Post a Comment