• 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

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

how to get value from array in laravel

Whats the point of running Laravel with the command 'php artisan serve'?

Laravel - How to properly generate unique slugs from article titles?

Calculating Median of an array in PHP

Laravel query builder binding parameters more than once

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Nginx RTMP not recording

Log a user out of a website when they put their computer to sleep

Display a success custom notice after Placing an Order in WooCommerce

Call to a member function fetch_field() on a non-object MySQLiDB

PHPS source file - 403 Forbidden You don't have permission to access this resource

Laravel PackageManifest.php: Undefined index: name

About Contact Privacy policy Terms and conditions