Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-02-2007, 11:23 AM   PM User | #1
plastik77
New to the CF scene

 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
plastik77 is an unknown quantity at this point
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']))
{
header("locationreview.php");
exit;
}
plastik77 is offline   Reply With Quote
Old 08-02-2007, 02:58 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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'])) {} .
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:38 AM.


Advertisement
Log in to turn off these ads.