• 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

Use Python plotly chart in PHP

Display specific shipping method if woocommerce product has specific acf field value

How to pass data to all views in Laravel 5?

Remove product downloads section in woocommerce email notifications

Get WooCommerce products from specific category

Clients authentication and user authentication with laravel

Why "Class 'GuzzleHttpClient' not found" even after Installing it in Laravel?

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

How update php.ini on a Mac OS X Mojave?

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Limit WooCommerce products in cart only from one custom taxonomy

How to separate letters and digits from a string in php

how to redirect the user back to desired URL after login page in PHP?

Passing a boolean value from checkbox in Laravel form

About Contact Privacy policy Terms and conditions