PHP session : do not increment the session every time I refresh the page
I created this code that increments the session variable every time I click on the button. I just don't want it to increment every time I refresh the page:
<?php
session_start();
// Page was not reloaded via a button press
if (!isset($_POST['add'])) {
$_SESSION['attnum'] = 0; // Reset counter
}
?>
<form method='post'>
<input name='add' type="submit" value='+'>
<h3><em>att<?php echo $_SESSION['attnum']++ ?>: </em></h3>
</form>
how can i set the session to increment only when i click on the button and not to increment when i refresh?