• 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

How to get AJAX to post on second page?

dompdf and img tag, image wont show

Connecting an HTML webpage to a SQL Server

How to use PHPCBF to fix one issue at a time?

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Wordpress 'post_type_link' hides permalink

How do I upload a laravel project on cPanel shared hosting?

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

Laravel - Browser displays message again when I press back button

Send Outlook 2010 email using PHP

Yii2: How do I debug console commands?

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Jquery DataTables: Data not displaying in table via Ajax

could not find driver Debian SQL Server PHP

Dropdown with current value from Mysql

About Contact Privacy policy Terms and conditions