• 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

Get image type from base64 encoded src string

Add record for each array elements if missing in table

How to test a php login connected to a mysql db through xampp?

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

Target Individual Form Instance/Counter Inside A PHP While Loop

PHPExcel export HTML table to xlsx

mysql slow on updates for a well optimized query

Sentry on Symfony: how to exclude `NotFoundHttpException`

500 Internal Server Error on Ajax request. Not sure the origin of the problem

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

WooCommerce: Add/display Product or Variation custom field everywhere

PHP date() with timezone?

Mobile browsers are adding .html to filename on download

Remove categories with all childs derived from parent category

How to redirect to another page after n seconds in wordpress without using javascript?

About Contact Privacy policy Terms and conditions