• 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

Must be of the type array, null given,

correct PHP headers for pdf file download

Laravel insert dynamic input values with radio button

Query Optimization, changing the queries in the loop into a single processing query

Laravel/docker-compose/redis - Class 'Redis' not found

How can i hide dt if dd got empty value

PHP usort() order in case of equality

Refresh specific HTML content that retrieves data from MySQL

Woocommerce redirect after add-to-cart error

MySQL - Connection failed: No route to host

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

Make Shipping Method fields Mandatory on Woocommerce checkout page

Backend cannot be reached after Typo3 login screen

Extract house numbers from address string

Send POST data via raw JSON with Postman

About Contact Privacy policy Terms and conditions