• 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

Yii2: How to download backup files using spanjeta/yii2-backup?

Get all WooCommerce products within own plugin

Access denied for user 'homestead'@'localhost' (using password: YES)

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

Wordpress add responsive srcset header image to theme

passwordless LDAP login and get user information using Kerberos ticket in PHP

MOODLE: What does it mean to aggregate h5p assets?

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

What will the best solution for this multiple optional filter?

Undefined variable in Laravel 8 project (php 7.4)

Parameter is not sent to Laravel route in Ajax

PHP -> Next nearest date defined by array of days in week

How to extract price from given url using Xpath?

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

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

About Contact Privacy policy Terms and conditions