• 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

PHPExcel file download using AJAX call

dockerizing Laravel + vue

How to put php code inside opening and closing shortcodes

Elastic Beanstalk with Laravel Envoy

how to validate form data in codeigniter 4

In PHP, which is faster: preg_split or explode?

merging two arrays with specified index

Laravel 8 factory state afterCreating

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Laravel insert dynamic input values with radio button

PHP - installing Xdebug on Mac with XAMPP (Unix File)

PHP SoapClient: set a namespace without prefix

PHP - CURL using HTTPS [closed]

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

How to create a video stream from a single dynamic image in PHP

About Contact Privacy policy Terms and conditions