• 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 UUID generation

How to get values inside <![CDATA[values]] > using php DOM?

html-php form submission after validation through JavaScript [closed]

Laravel display validation error

"There is no active transaction" when refreshing database in Laravel 8.0 test

How to prevent phpmailer sending embedded image as an attachment on Gmail?

how to remove white space in select 2

Converting alphabet letter to alphabet position in PHP [duplicate]

file_get_contents() without "Http" to access external URL [closed]

Insert a DIV after the 6th product only once in WooCommerce category archives

Required field only if another field has a value, must be empty otherwise

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

I cannot create a auto generated date time in mysql workbench

301 Redirect to remove query string on homepage only

PHPSpreadsheet - How Do I Use Auto Migration Tool

About Contact Privacy policy Terms and conditions