• 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

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

Google Gmail API - How to login programatically?

Sum array values of a column within each column of an array with 3 levels

I want to display default profile image if user do not have profile image

Declaration of OMDb::query(string $statement) must be compatible with PDO::query

Modify microseconds of a PHP DateTime object

How to keep value of selected value after form submission?

How to insert Google Adsense Code in PHP script?

Xdebug in Laravel is not working with VSCode

Cant seem to get the Pagination to work on my WooCommerce REST API application?

correct PHP headers for pdf file download

Group rows by column and sum another column within groups [duplicate]

php code to send checkbox form results to email

Check If array is null or not in php

PHP Slim Framework request using withAttribute error

About Contact Privacy policy Terms and conditions