Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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