Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: PHP Form help

  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Thanked 0 Times in 0 Posts

    PHP Form help

    Hi, i'm trying to resolve a problem i have when processing a large form with 2 possible submit buttons. I am using PHP server self and running the script at the top of the page. Regardless of which button is pressed, the form data should be inserted into the database. The only difference is that one button will redirect to another page. When i test for which button has been pressed, however, I don't want to have to repeat all the insert statements for each IF statement. However, I can't use if (isset($_POST)) as the page prior to the current one is also a form, therefore the if (isset($_POST)) statement tries to execute the data on the first loading of the page, which shouldn't happen. If anyone knows how I can avoid having to repeat the insert statements, i'd be grateful for any pointers. Not actually sure if any of this makes any sense!

    this is current incorrect php code which isn't working as it is executing the statements on the first page load

    if (isset($_POST))

    ...all the statements

    //go to confirm test page
    if (isset($_POST['SubmitProceed']))

  2. #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Thanked 637 Times in 625 Posts
    You should never do a isset($_POST) check; as you have found, it will always be true, because it'll always be an array, just empty sometimes.

    You can do an OR "if" statement instead-- if (isset($_POST['SubmitProceed']) || isset($_POST['theOtherSubmit'])) {} .


Posting Permissions

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