...

View Full Version : PHP Form help



plastik77
08-02-2007, 11:23 AM
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']))
{
header("location:preview.php");
exit;
}

Fumigator
08-02-2007, 02:58 PM
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'])) {} .



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum