• 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

How to display MySQL table using php and edit it in a web browser

WooCommerce - unset "<product> removed notice…" on cart page

Sum column values from multiple arrays

Symfony/Form add attribute based on the data

Group data in a multidimensional array based on two columns

Filter WooCommerce related products by Polylang language

*** ERROR *** The PHP configuration loaded file is: c:/wamp64/bin/php/php8.1.0/php.ini - should be: c:/wamp64/bin/apache/apache2.4.53.1/bin/php.ini

Can't exclude directories from .htaccess mobile redirect?

xdebug 3 not working in ubuntu 20.04 with docker

Undefined Array Key error when uploading image on php

How to validate tin and cst using PHP?

How to create a scheduler application in php

Symfony Mercure "Failed to send an update"

PHP Include for HTML?

PHP - Store information with NO database

About Contact Privacy policy Terms and conditions