• 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

Prestashop cUrl Login

PHP AWS Cognito 'Error executing "SignUp" : ResourceNotFoundException : User pool client XXXX does not exist

CSS file not imported in laravel blade view

how to search for a file with php

Getting public posts of a random user from Facebook API

Move a child array to parent array and change parent/child name

How to install php yaml on CentOs?

Live search query using JS and PHP for QA forum

Inserting data into SQL Server Db An Invalid direction was specified

Entity provider not working in security.yml php symfony3.4 ({"code":401,"message":"bad credentials"}.)

User pool client {id}does not exist

Debugging Stripe Webhook Event

merging two arrays with specified index

Doctrine 2 mapping referencing unique key

PHP Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20

About Contact Privacy policy Terms and conditions