• 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 can I easily switch between PHP versions on Mac OSX?

What is the function of the (new Date()).getTime() in PHP?

Merge key and value of array index [duplicate]

PHP file_get_contents function

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

yii2 and mssql insert varbinary into model

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

add_action() function in wordpress not working [duplicate]

Trying to iterate over a mongodb cursor twice - failing

How to pass data to all views in Laravel 5?

Check If array is null or not in php

MongoDB Duplicate Documents even after adding unique key

Refresh specific HTML content that retrieves data from MySQL

VB.NET WebRequest with PHP POST

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

About Contact Privacy policy Terms and conditions