• 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 data-value with variable value

How to convert the int value to inch in PHP [closed]

Cannot pass null argument when using type hinting

TesseractOCR not working for Laravel

Unable to guess the mime type as no guessers are available Laravel 5.2

How to add a custom field to all Woocommerce attribute terms using add_action

Get image type from base64 encoded src string

Getting output of MS stored procedure on php call

SQL to convert multiple rows into a single row of variable length

best way to store error messages in Laravel (session or variable)

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

If you intend you use SMTP, add your SMTP Code after this Line

Laravel csrf token mismatch for ajax POST Request

Utf8 encoding issue with Laravel

Google API Heatmap Layer exception, why?

About Contact Privacy policy Terms and conditions