• 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 do I loop through an MS SQL database with VB.NET?

PHP returning an error message and false

Dropzone: Submit both form data and dropzone at once

Session timeout in Yii2

Manage independently the decimal number of the price of each product [duplicate]

Assign output of PHP function to a variable

php file upload scanning using clamav, permissions on /tmp/

how to sort by a custom appended relation to model

array_map triple dimensional array [duplicate]

How to to send mail using gmail in Laravel?

How to set dynamic `home` and `siteurl` in WordPress?

Adding the custom page with add_menu_page function on Wordpress

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

Boolean assignment operators in PHP

mysql_result is defined but mysql_free_result warns it expected a resource

About Contact Privacy policy Terms and conditions