Jump to content

mbschoch

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by mbschoch

  1. 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']; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.