• 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 do I call Validator from a namespace with an already existing Validator class

PHP Deprecated issue when running artisan command

Implode columnar values between two arrays into a flat array of concatenated strings

Fatal error: Array callback has to contain indices 0 and 1

Laravel You requested 1 items, but there are only 0 items available

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

Extract house numbers from address string

Laravel Jetsream Profile page not loading on fresh install

Convert PHP array into HTML tag attributes separated by spaces

curl returning 301 error after migrating to https

array_key_exists(): The first argument should be either a string or an integer

WordPress - Dynamically add user ID to the end of a URL

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

Custom add to cart button URL for specific product in WooCommerce?

How can I make a full text index of the column?

About Contact Privacy policy Terms and conditions