• 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

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

PHP only Hit Counter?

Issue saving card for customer

browsersync doesn't work with XAMPP

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

Laravel 5.2: Unable to locate factory with name [default]

Install mysql client in docker image

Remove country code from phone number?

Nginx RTMP not recording

Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

How to make a array inside array?

How can I get new CSRF token in LARAVEL by using ajax

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

Creating Combinations of Elements

About Contact Privacy policy Terms and conditions