1. <?php
  2. // Define the maximum number of submissions allowed.
  3. define('MAX_SUBMISSIONS', 5);
  4. // Initialize a counter for submissions.
  5. $submissionCount = 0;
  6. // Check if the form has been submitted.
  7. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  8. // Increment the submission counter.
  9. $submissionCount++;
  10. // Check if the submission limit has been reached.
  11. if ($submissionCount > MAX_SUBMISSIONS) {
  12. // Display an error message.
  13. echo "Error: You have exceeded the maximum number of submissions (" . MAX_SUBMISSIONS . ").";
  14. } else {
  15. // Process the form data (replace with your actual form processing logic).
  16. echo "Form submitted successfully!";
  17. // Example: Print the submitted data (for debugging)
  18. print_r($_POST);
  19. }
  20. }
  21. ?>
  22. <!-- Your form here -->
  23. <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
  24. <!-- Add your form fields here -->
  25. <input type="text" name="name">
  26. <input type="submit" value="Submit">
  27. </form>

Add your comment