• 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

Laravel Jetsream Profile page not loading on fresh install

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

How to fix bootstrap multiselect search data using ajax

protect images from being copied

Calculating Median of an array in PHP

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

How can I pass the list to the component variable in Laravel?

Attempted to call an undefined method named "get" of class "MailController"

Laravel s3 upload file with metadata using pre-signed url

How to make dot match newline characters using regular expressions

No definition found for function in vendor vscode

Applying programmatically a coupon to an Order in WooCommerce3

PHP Form Not Inserting

codeigniter 4 running error first time with xampp

Add and update products to session cart in Laravel

About Contact Privacy policy Terms and conditions