Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Cases with Multiple Form Submissions

    My form posts the data to the same page. Since there are multiple forms that could be submitted to the same page I need to have logic to determine which form is submitted. I would first create a switch to determine which form was submitted checking for a particular POST value. I need to create a hidden field on each form to identify the form.:

    PHP Code:
    if(isset($_POST)
    {
        
    //Form was submitted - determine the form
        
    switch($_POST['formID'])
        {
            case 
    "form1":
                
    processForm1();
                
    $page="xxx.php";
                break;
            case 
    "form2":
                
    processForm1();
                
    $page="yyy.php";
                break;
        }

    The $page value would represent which content to show in the page when it reloads. Although this may be different based upon the outcome of the form processing (i.e. form passed, form had invalid data, etc.)

    So, now that I have a value ($page) to determine what content to show I could simply include it by default in the page.

    PHP Code:
    <div id=content>
    <?php
        
    if ($page)
        {
            include(
    $page);
        }
    ?>
    </div>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    And your question is?
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    I'm sorry. Just wondering if it looks good the form of it and all and if it does what should it be put for formid.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •