[Solved] php variable changes when clicked on html link [closed]


Try this, is PHP:

<?php
if (isset($_GET['money'])) {
    $money = rob_shop($_GET['money']);
    echo 'You now have: '.$money.'<br>';
} else {
    $money = 100;
    echo 'You now have: '.$money.'<br>';
}
echo '<a href="https://stackoverflow.com/questions/27303586/?money=".$money .'">rob a shop</a>';
function rob_shop($money){
    $money = $money + 75;
    return $money;
}
?>

But the best way to do it is with ajax to avoid refreshing the page.

solved php variable changes when clicked on html link [closed]