• 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

cakephp save drag and drop list order to database

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

How to get variable from JavaScript to PHP [duplicate]

How to add automatically collapse/expand in content wordpress (single.php)?

Connecting an HTML webpage to a SQL Server

How to display table header in every page using FPDF library?

AJAX call fails with SyntaxError: Unexpected end of JSON input

Make survey at laravel 5.4 and MySQL

how to get value from array in laravel

How to redirect to another page and call a Function there on Angular ng-click

How to pass data to all views in Laravel 5?

Laravel 5 session not persisting after user is logged in

Statement that checks whether a URL contains a particular path?

Using PHP to connect to a remote MSSQL database

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

About Contact Privacy policy Terms and conditions