• 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

Using Associative arrays

Toggle between a textbox and a select using PHP

How to use $this->session->set_userdata in codeigniter

Sort a multidimensional array by integer inside of a string value which is two levels down

Laravel 5 issue with wherePivot

How do I get friend list from Friends table with counts of friends of my friends

PHP mail sending empty mails

I want to display default profile image if user do not have profile image

PHP each() function replacement

Mysqli Output to a table

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

Edit XML in HTML form and submit to self

XSS attack still works despite htmlspecialchars() doing its work

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

WordPress Subquery returns more than 1 row on SELECT

About Contact Privacy policy Terms and conditions