• 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

Get WooCommerce product variation attribute terms in admin products general box

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

Move a child array to parent array and change parent/child name

Webscraping Symfony/Panther: Can't get HTML

PHP SoapClient: set a namespace without prefix

Dynamic table in HTML using MySQL and php

args[max_input] woocommerce if statement confused

How to redirect to another page after n seconds in wordpress without using javascript?

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

How to get Laravel's CSRF Token from Another Website?

Use same method for inertia response and json response Laravel Jetstream

PHP rotate matrix counter-clockwise

Symfony - "framework.test" config is not set to true

PHP and WebView - Cookie doesn't are the same

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

About Contact Privacy policy Terms and conditions