Jump to content

[Help] Processing diffrent forms on one page using if statement


gtrufitt

Recommended Posts

Hi,

 

I have multiple forms on one page that are used to UPDATE a user's information, each form has its own submit button and the action is

<?php echo $SERVER['PHP_SELF']; ?>

to bring the form back to the page. I am slightly unsure of the code needed to process each from depending which one has been changed eg:

 

if (the form name) has been changed

UPDATE something

else

if (another form name) has been changed

UPDATE something different

 

etc.

 

What is the correct php code to use with the if statement in order to update each form depending on which form has been changed?

 

Thanks,

 

Gareth

Link to comment
Share on other sites

<?php
if (isset($_POST['Submit1']))
{
// do me!
}
else if (isset($_POST['Submit2']))
{
// no me!
}
else if (isset($_POST['Submit3']))
{
// what about me?
}
?>
<form>
<!-- the form -->
<input type="Submit" name="Submit1" value="Submit1" />
</form>
<form>
<!-- the form -->
<input type="Submit" name="Submit2" value="Submit2" />
</form>
<form>
<!-- the form -->
<input type="Submit" name="Submit3" value="Submit3" />
</form>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.