Detecting dynamic form submissions with php

David Carr

Tutorials PHP & MySQL

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
}

 

Read articles directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Copyright © 2006 - 2024 DC Blog - All rights reserved.