• 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

Respond with status code 401 on authentication failure using Laravel and Passport?

Python - Include another Python script

Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

PHPExcel How to set conditional formatting to change cell background color based on cells values

Wordpress add responsive srcset header image to theme

Error converting docx to pdf using Unoconv

Laravel get user data with profile

How to load Codeigniter 4 lang file into an array variable

Project structure for PHP

if statement inside concatenation

Combine multiple columns into an array as one of the key in a results set

Yii2 select2 database exception number of bound variables does not match number of tokens

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

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

PHP password_verify

About Contact Privacy policy Terms and conditions