I need a circle to grow every time a button is cumulatively clicked, which means it needs to be server stored and not locally stored. As of now, I have managed to count the clicks via this php code, which stores in a .txt file the amount of times the button has been clicked:
<?php
if( isset($_POST['clicks']) ) {
incrementClickCount();
}
function getClickCount()
{
return (int)file_get_contents("clickit.txt");
}
function incrementClickCount()
{
$count = getClickCount() + 1;
file_put_contents("clickit.txt", $count);
}
?>
I would like to extract the number in the clickit.txt and use it to increment, with jquery, the size of a circle via css.
var numberClicks = ${'#number-clicks', 'value'}
$('.main-circle').css('width', 'numberClicks', 'vw')
.main-circle {
position: fixed;
width: 1vw;
height: 1vw;
top: 50%;
bottom: 50%;
left: 50%;
border-radius: 50%;
background-color: yellow;
transform: translate(-50%, -50%);
}
<div class="main-circle"></div>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" value="neuer erfolg" name="clicks">
</form>
<div>Click Count: <span id="number-clicks"<?php echo getClickCount(); ?> </div>
I know this doesn't work as is, but I can't figure out the correct syntax. Any help is much appreciated!