---
title: "How to Increment a Count on Each Form Submission - Convert Forms"
description: "Every submission in Convert Forms receives a unique, sequential ID that identifies it across all forms. However, sometimes you may want a counter star"
url: "https://www.tassos.gr/docs/convert-forms/functionality/sequential-number-per-form"
date: "2026-04-17T07:27:48+00:00"
language: "en-GB"
---

[ Home ](https://www.tassos.gr/index.php?option=com_content&view=category&layout=blog&id=24&Itemid=1088) / [ Convert Forms ](https://www.tassos.gr/index.php?option=com_content&view=category&id=43) / [ Functionality ](https://www.tassos.gr/index.php?option=com_content&view=category&id=60)

#  How to Increment a Count on Each Form Submission

Every submission in Convert Forms receives a **unique**, **sequential ID** that identifies it across all forms. However, sometimes you may want a counter starting from 1 for each form—useful for things like per-form reference numbers, ticket IDs, or order numbers.

This guide shows you how to **add an auto-incrementing counter** to your form using a simple PHP snippet. The counter is stored in a **Hidden field** and increases with every new submission for that specific form. You can also format the counter with **leading zeros** (e.g., 00001, 00002) for a consistent, professional appearance.

## [Setting Up the Form](#setting-up-the-form)

1. Open the form builder by creating or editing your existing form.
2. Add a **Hidden** field (found under the Add Fields tab). Users won’t see this field, but it will store the counter value behind the scenes.
3. After adding the field, set its name to **`total`**.

## [Adding the Code Snippet](#adding-the-code-snippet)

Place the following PHP script into the **PHP Scripts → Form Process** option:

 ```
// Name of the Hidden field that will store the counter
$myFormField = 'total';

// Minimum number of digits for the counter (e.g., 5 will produce 00001, 00002, ...)
$minDigitLength = 5;

// Get all submissions for this form (with any state)
$formSubmissions = ConvertForms\Api::getFormSubmissions($form['id'], ['state' => [0,1,2]]);

// Calculate the new counter value by adding 1 to the current number of submissions
$newTotalSubmissions = count($formSubmissions) + 1;

// Pad the counter with leading zeros if needed
if ($minDigitLength > 0)
{
    $newTotalSubmissions = str_pad($newTotalSubmissions, $minDigitLength, '0', STR_PAD_LEFT);
}

// Store the counter value in the Hidden field
$post[$myFormField] = $newTotalSubmissions;

```

## [How It Works](#how-it-works)

1. **Field Configuration**: The variable `$myFormField` specifies which form field will store the counter value (in this case, `total`).
2. **Setting Minimum Digits**: The `$minDigitLength` variable defines how many total digits the number should have (default is 5). For example, with five digits, the first submission would be `00001`.
3. **Getting Submissions**: The script retrieves all existing submissions for your form, including those with any state (published, unpublished, or archived).
4. **Calculating the New Count**: It counts the existing submissions and adds 1 to create the new incremental number.
5. **Adding Leading Zeros**: If `$minDigitLength` is set greater than 0, the script will pad the number with leading zeros to match that length.
6. **Assigning the Value**: Finally, the counter value is stored in your hidden field named `total`.

## [Testing Your Counter](#testing-your-counter)

1. Submit a test submission through your form.
2. Check the submission in **Convert Forms » Submissions**. You should see your incremental number stored in the Hidden field.
3. Submit another test entry to confirm the number increases as expected.

**Note**: If you want to display this number in your email notifications or confirmation messages, simply add the shortcode {field.total} to any message in your form’s Notifications or Confirmations settings.

 Last updated on May 16th 2025 09:05

## Schema

```json
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "itemListElement": [
        {
            "@type": "ListItem",
            "position": 1,
            "name": "Home",
            "item": "https://www.tassos.gr"
        },
        {
            "@type": "ListItem",
            "position": 2,
            "name": "Home",
            "item": "https://www.tassos.gr/docs"
        },
        {
            "@type": "ListItem",
            "position": 3,
            "name": "Convert Forms",
            "item": "https://www.tassos.gr/docs/convert-forms"
        },
        {
            "@type": "ListItem",
            "position": 4,
            "name": "Functionality",
            "item": "https://www.tassos.gr/docs/convert-forms/functionality"
        },
        {
            "@type": "ListItem",
            "position": 5,
            "name": "How to Increment a Count on Each Form Submission",
            "item": "https://www.tassos.gr/docs/convert-forms/functionality/sequential-number-per-form"
        }
    ]
}
```

```json
{
    "@context": "https://schema.org",
    "@type": "Article",
    "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.tassos.gr/docs/convert-forms/functionality/sequential-number-per-form"
    },
    "headline": "How to Increment a Count on Each Form Submission",
    "image": {
        "@type": "ImageObject",
        "url": "https://www.tassos.gr/"
    },
    "publisher": {
        "@type": "Organization",
        "name": "Tassos",
        "logo": {
            "@type": "ImageObject",
            "url": "https://www.tassos.gr/https://www.tassos.gr/media/brand/logo-text.png"
        }
    },
    "author": {
        "@type": "Person",
        "name": "Tassos Marinos",
        "url": "https://www.tassos.gr/docs/convert-forms/functionality/sequential-number-per-form"
    },
    "datePublished": "2025-05-16T09:45:59+03:00",
    "dateCreated": "2025-05-16T09:45:59+03:00",
    "dateModified": "2025-05-16T09:53:08+03:00"
}
```
