• 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

args[max_input] woocommerce if statement confused

Unable to uninstall brew php from homebrew

In PHP, which is faster: preg_split or explode?

How to use React Router with Laravel?

Applying programmatically a coupon to an Order in WooCommerce3

Prestashop webservice API creating cart rules

Adding one microsecond to Datetime object in PHP

Laravel Collections. Is there some kind of assertStructure method?

PHP: remove filename from path

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

How to load Codeigniter 4 lang file into an array variable

PHP | "The requested PHP extension bcmath is missing from your system."

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

Insert And Retrieve Data in MySQL with $.post Noob Question

Laravel Command Schedule Not Working Properly

About Contact Privacy policy Terms and conditions