• 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

Parameter is not sent to Laravel route in Ajax

How to get the total hour from starting time to end time in php

How to pass security cloudflare server with php curl

how can I set a session variable in Drupal 8 and get it in a php script?

How to change HTML structure inside WP <head>

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

Convert PHP array into HTML tag attributes separated by spaces

hidden INPUT value not available in $_POST

how to remove %20 in the url in php

calling server using nusoap with complextype

Add custom text under order details on WooCommerce My account view order pages

Clients authentication and user authentication with laravel

Woocommerce redirect after add-to-cart error

How to get Laravel's CSRF Token from Another Website?

PHP Print to Network Printer

About Contact Privacy policy Terms and conditions