Re: Multiple submit's on one form

From: Date: Wed, 07 Aug 2002 18:40:04 +0000
Subject: Re: Multiple submit's on one form
Groups: php.general 
Request: Send a blank email to php-general+get-111559@lists.php.net to get a copy of this message
Regardless of whether or not you use a switch() or if () elseif(); - i think a good way to accomplish what you are trying to do would be to have the form post to myphpcode.php and in that file, have something like: <? if ($B1 == "Save"){ include "myphpcode1.php" } elseif ($B2 == "Back"){ include "myphpcode2.php" } etc.. etc.. etc.. ?> This way, all the rest of the form fields (if any) are preserved. if you use the header("location:"); method mentioned by other posters, you will lose any other fields in that form, unless you manually add them to the URL after location: . if you don't have any other relevant fields, then it doesn't really matter. jerome
From: "Saci" <nospam@bol.com.br> I have a form working well and I need 4 different submit buttons, something like this <form method="POST" action=myphpcode.php> <table border="0" cellpadding="1" bgcolor="#E0DFE3"> ... .. .. .. .. <tr>
    <td bgcolor="#E0DFE3">
    <input type="submit" value="Save" name="B1"></td>
    <td bgcolor="#E0DFE3">
    <input type="submit" value="Back" name="B2"></td>
    <td bgcolor="#E0DFE3">
    <input type="submit" value="Refresh" name="B3"></td>
    <td bgcolor="#E0DFE3">
    <input type="submit" value="Search" name="B4"></td>
</tr> </table> </form> </body> </html> I would like to call 4 different php pages according to the one of the 4 buttons pressed. Button B1 will post to myphpcode1.php Button B2 will post to myphpcode2.php Button B3 will post to myphpcode3.php Button B4 will post to myphpcode4.php
_________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com

« previous php.general (#111559) next »