• 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

PHP: remove filename from path

Performance of foreach, array_map with lambda and array_map with static function

Send same name multiple checkbox values via ajax

PHPExcel_IOFactory::createWriter causes wrong behaviour

Encrypt in php and decrypt in Dart(flutter)

Undefined Array Key error when uploading image on php

str_replace or preg_replace random number from string

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Google API Heatmap Layer exception, why?

Not able to override collapsible.js in magento 2

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

Require a class from another class - php

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

How to display MySQL table using php and edit it in a web browser

Symfony there are no commands defined in the "make" namespace

About Contact Privacy policy Terms and conditions