working on a simple counter program
when button is pressed it adds 1
when other button is pressed it minuses 1
once variable reaches 10, i need it to set the variable to zero
i’m completely new to php, but i know c++, and in c++ i’d do a do-while loop for this
suggestions?
<?php
session_start();
$_SESSION['number'] = ((isset($_SESSION['number'])) ? $_SESSION['number'] : 0);
if(isset($_GET['add'])){
$_SESSION['number']++;
}
if(isset($_GET['minus']))
{
$_SESSION['number']--;
}
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="get">
<input type="submit" style = "width:100px; height: 100px;" name="add" value="add" /> <br><br>
<input type="submit" style = "width:100px; height: 100px; " name = "minus" value="minus" />
</form>
<?
echo $_SESSION['number'];
?>
It is triggered for each request by the framework.