I have a form with the normal
[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 ?
I have a form with the normal
[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
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 “
Please enter your name, e-mail and comment.
NameE-mail
Comments
I promise ! :’(
Dont think i done bad though being self taught !
Thank you again !