• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Increase value by 1 on button click

php


PHP Snippet 1:

<form action="" method="post">
<input type="submit" name="click_button" value="Click..">
</form>
<?php
session_start();

if (isset($_POST['click_button'])) {
    $_SESSION['clicks'] += 1 ;
} else {
    $_SESSION['clicks'] = 0;
}

echo($_SESSION['clicks']);

Related Snippets

Laravel unique validation on multiple columns

Redirect to previous page with php

file_put_content...fail to open stream:Permission denied in Laravel 5

What is the function of the (new Date()).getTime() in PHP?

What is PHP's equivalent of JavaScript's "array.every()"?

renameColumn migration fails for existing column with columns does not exist error

Limit of log line written to Apache Errorlog from mod php error_log

Query Optimization, changing the queries in the loop into a single processing query

PHP's array_map including keys

Add New Parameter to Existing URL using htaccess

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

How to override header set in Apache config with more specific header in a virtual host

Comma separated list from array with "and" before last element

Normalize DateInterval in PHP

How to override htaccees file for cache control header

About Contact Privacy policy Terms and conditions