0

I am creating a game and in that game to get coins you have to click a button but I do not know how to. What I thought first was to create a button in HTML then a PHP variable and make it so that when you click the button the variable value goes up by one and starts at zero. But I thought how do you control a HTML button with PHP.

Here is my code already made, MAKE SURE TO READ THE LINES OF COMMENTS IN THE CODE

<?php
    $coin = 0; //the variable that shows you your coins
    echo 'You have ' .$coin;
    echo <<<_END
        <img src="coin.png" width="2%" alt="coins">
    _END;
    echo <<<_END
    <button>More!</button> //button that makes your coins go up by one
    
    _END;
    
    ?>

Thanks, PHPcrazcode

Jason
  • 47
  • 6
  • You want javascript, with a possibility of ajax to interact with PHP. PHP runs before the page is sent to the browser, so by the time it gets to the user, PHP is done. Javascript runs in the browser after the page has been sent. – aynber Dec 22 '21 at 21:00
  • @aynber do I just link javascript into the page normal? – Jason Dec 22 '21 at 21:01

0 Answers0