<?php
// Define the maximum number of submissions allowed.
define('MAX_SUBMISSIONS', 5);
// Initialize a counter for submissions.
$submissionCount = 0;
// Check if the form has been submitted.
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Increment the submission counter.
$submissionCount++;
// Check if the submission limit has been reached.
if ($submissionCount > MAX_SUBMISSIONS) {
// Display an error message.
echo "Error: You have exceeded the maximum number of submissions (" . MAX_SUBMISSIONS . ").";
} else {
// Process the form data (replace with your actual form processing logic).
echo "Form submitted successfully!";
// Example: Print the submitted data (for debugging)
print_r($_POST);
}
}
?>
<!-- Your form here -->
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<!-- Add your form fields here -->
<input type="text" name="name">
<input type="submit" value="Submit">
</form>
Add your comment