Jump to content

[SOLVED] form action = [file.php or file2.php] ?


hassank1

Recommended Posts

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

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 }

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.