PHP & MySQL | Tutorials

David Carr

Detecting dynamic form submissions with php

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
}

 

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2020 DC Blog. All code MIT license. All rights reserved.