hassank1 Posted December 29, 2008 Share Posted December 29, 2008 Hi I've a form that contain an array of checkboxes (check[]) user can either check some boxes and [delete] , or [send] a msg to them so if user press delete I want the $_POST[check] to go to delete.php or if user press send I want the $_POST[check] to go to send.php Link to comment https://forums.phpfreaks.com/topic/138712-solved-form-action-filephp-or-file2php/ Share on other sites More sharing options...
DimitriDV Posted December 29, 2008 Share Posted December 29, 2008 Hi I've a form that contain an array of checkboxes (check[]) user can either check some boxes and [delete] , or [send] a msg to them so if user press delete I want the $_POST[check] to go to delete.php or if user press send I want the $_POST[check] to go to send.php form action = file.php in file.php you enter your condition if $_POST[check] = 'delete' { all code that is mentioned in delete.php } if $_POST[check] = 'send' { code from send.php } Link to comment https://forums.phpfreaks.com/topic/138712-solved-form-action-filephp-or-file2php/#findComment-725214 Share on other sites More sharing options...
hassank1 Posted December 29, 2008 Author Share Posted December 29, 2008 the $_POST[check] contains an array of numbers to send a msg to .. it doesn't contain (delete or send) I've 2 buttons ( delete ) and another called (send) Link to comment https://forums.phpfreaks.com/topic/138712-solved-form-action-filephp-or-file2php/#findComment-725218 Share on other sites More sharing options...
redarrow Posted December 29, 2008 Share Posted December 29, 2008 You can use two forms pointing to the correct page. or use a header() function, when submitting the correct data. Link to comment https://forums.phpfreaks.com/topic/138712-solved-form-action-filephp-or-file2php/#findComment-725271 Share on other sites More sharing options...
kenrbnsn Posted December 29, 2008 Share Posted December 29, 2008 If you post your code between tags, we could help you better. But, in general, the way to do this is: <?php if (isset($_POST['submit'])) { switch ($_POST['submit']) { case 'delete': // // code for delete here // break; case 'send': // // code for send here // break; } } ?> <form action="" method="post"> <input type="checkbox" name="abc" value="abc">abc<br> <input type="checkbox" name="xyz" value="xyz">xyz<br> <input type="submit" name="submit" value="send">Send <input type="submit" name="submit" value="delete"> </form> Note: not checked for syntax errors Ken Link to comment https://forums.phpfreaks.com/topic/138712-solved-form-action-filephp-or-file2php/#findComment-725367 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.