PHP Form with two different action buttons.

I have a form with the normal

[php]

Quantity: Unit Value: [/php]

IS IT POSSIBLE ?? to have two buttons but then have each button a different action for the same form ??

Reason to post to one item or another ?

Give each submit button a unique name then check for that value.

(Pseudo code)

        <input type="submit" name="action1" value="Action One" >

        <input type="submit" name="action2" value="Action Two">

if $_POST ==‘action1’{ do this}

if $_POST ==‘action2’{ do that}

HI Kevin. I think I maybe looking at this one too hard as I cannot see how this works.

I have set the form action at the top to where the variables are being sent yet when I press each button at the bottom I want do not necessarily want it to use that. So how do I do away with the initial updaterecord.php and have the button decide which php file I am posting to ?

IE I want …
BUTTON1

<form action='updaterecord1.php' method='post> BUTTON2 <form action='updaterecord2.php' method='post> <p>as each update is changing data in a different table.</p> <p>hope this makes sense.</p> <p>Paul</p>

Post both the the same file, then decide what you are doing based on the button submitted. You can even post the same file your form is on, then make your choice to handle it.

Hi Kevin.

Sorry for late reply as i could not access the site earlier.

Appreciate your replies to my question however i could not get my head round the problem which is more probably down to my not knowing how to solve this using your advice.
I have created a work around to the problem for now but i am keen to undertake what you have said it just how to manage the data sent from one page to the next and how to decide which one i need as to which table i am updating.

Thank you again for you valued help and advice with this.

Regards Paul

PS. I have maked this topic as solved as the advice i have been given is sound its just i cannot see how to implement this in my pages at this time.

Here is a working example. You can use this as long as you promise to NEVER EVER use tables to format your forms.

[php]<?php
if (isset($_POST[‘submit1’])){
//Do Something
echo “I clicked Submit 1”;
}
if (isset($_POST[‘submit2’])){
//Do Something Else
echo “I clicked Submit 2”;
}

echo “

”;
print_r($_POST);
echo “
”;
?> Feedback Form /* This CSS block defines element formatting */ body { font-family: Arial, Helvetica, sans-serif; font-size: 15px; } h1 { color: #0066CC; } input, textarea { margin-top: 5px; /* Add some space */ margin-bottom: 15px; } label { font-weight: bold; /* Show labels in bold */ }

Feedback Form

Please enter your name, e-mail and comment.

Name

E-mail


Comments


 



Author information goes here. [/php]

I promise ! :’(

Dont think i done bad though being self taught !

Thank you again !

Sponsor our Newsletter | Privacy Policy | Terms of Service