• 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

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

Open a popup box after receiving result from ajax

Remove product downloads section in woocommerce email notifications

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

PHP Deprecated issue when running artisan command

How avoid Moved Permanently The document has moved here

PHP Slim Framework request using withAttribute error

Add 2 Webcam in one page with WebcamJS

PHP - installing Xdebug on Mac with XAMPP (Unix File)

PHP only Hit Counter?

How to install ZeroMQ for PHP on an Alpine Linux container?

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

how to upload binary image to sql server using php laravel

Detect if PHP session exists

How to use PHPCBF to fix one issue at a time?

About Contact Privacy policy Terms and conditions