Detecting dynamic form submissions with php

David Carr

1 min read - 14th Dec, 2013

Here's a very simple way to detect if a form has been submitted, I've recently wrote a plugin for dynamic forms. 

The problem I had was being able to detect when a form was submitted, normally I would check for submit name array within the post array but since the plugin allows for full control over the form's elements including the submit button's name I had to do it a different way.

I could of had a hidden field in the form and then check for that but a much simpler way is letting the server detect the method request:

if($_SERVER['REQUEST_METHOD'] == 'POST'){
//submitted
}

 

0 comments
Add a comment

Copyright © 2024 DC Blog - All rights reserved.