• 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

Appending data to an anchor tag

How do I truncate a decimal in PHP?

How to send image,audio or video through the WhatsApp API - PHP

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

Reload parent page after submit in iframe

Artisan, creating tables in database

How to insert data from multiple select dropdown values into database?

Why isn't my PHP exception working?

Store multiple fields in JSON column (Nova CMS)

Laravel print last executed SQL query with Query log

PHP each() function replacement

PHP drop down list using array's and foreach (else and for) code

If action is on a different page do I use fwrite function

Laravel 5.1 Unknown database type enum requested

Access relation of pivot table in Laravel

About Contact Privacy policy Terms and conditions