Is it possible to generate automatic numbering in PHP after printing a form?

To generate automatic numbering in PHP after printing a form, you can use a counter variable that increments each time a new form is printed. This counter can be stored in a session variable to persist its value across page loads. By incrementing the counter and displaying it alongside the form, you can achieve automatic numbering.

<?php
session_start();

if (!isset($_SESSION['counter'])) {
    $_SESSION['counter'] = 1;
} else {
    $_SESSION['counter']++;
}

echo "Form #" . $_SESSION['counter'] . "<br>";
echo "<form method='post' action='submit.php'>";
// Your form elements here
echo "</form>";
?>