Hello, I am learning php in a class for school and I was hoping I could get some help with some code. I am trying to make a game life counter. I just want it to have simple +1, -1 and reset buttons. I have gotten it to add and subtract the first time, but it will not continue adding/subtracting. Thank you for any help you can give. Here is the code I'm having issues with:
<?php
session_start();
?>
<form method="post" action ="">
<input type="submit" name="name" value="Add"/>
<input type="submit" name="name" value="Minus"/>
<input type="submit" name="name" value="Reset"/>
</form>
<?
lifeTotal();
function lifeTotal()
{
$_SESSION['total']=20;
if($_POST["name"] == 'Add')
{
$_SESSION['total']++;
echo $_SESSION['total'];
}
else if($_POST["name"] =='Minus')
{
$_SESSION['total']--;
echo $_SESSION['total'];
}
}
?>