Black Friday sale is now on! 50% off Laravel: The Modular Way. Learn more

Detecting dynamic form submissions with php

David Carr

PHP & MySQL Tutorials

    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
    }

     

    Laravel Modules Book by David Carr

    Help support the blog so that I can continue creating new content!

    Subscribe to my newsletter

    Subscribe and get my books and product announcements.

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