-1

An HTML button looks like this:

<form name="HAHA" id="login_form" action="show.php" method="post">

The action of this button is show.php. That is just 1 action.

How would I use two actions?

<form name="HAHA" id="login_form" action="show.php","show2.php" method="post">

Does this work? Now I have 2 actions. Or do I have to use an Array?

Jonis
  • 415
  • 2
  • 6
  • 7

3 Answers3

2

If I understand your question right, you could create a new_action.php with a code like this:

<?php
  include('show.php');
  include('show2.php');
?>

in HTML you have to change the action attribute to

<form method="POST" action="new_action.php" name="form" id="form">
Thomas1703
  • 1,152
  • 5
  • 16
  • 33
1

No.

The action is an URL to send values from the form and get the response. The browser can process only one response. There are two solution for this limitation.

  1. Send form by asynchronous JavaScript and write own logic to process responses.
  2. Create one server side script as one, new action. The script process work of those many actions You want to put into form.
Michas
  • 8,534
  • 6
  • 38
  • 62
0

As Thomas1703 said just make the single action and in the php file do everything.

example:

<form action="myphp.php" method="POST" />
  <input type="submit" value="lets say Hello"   name="action1"/>
  <input type="submit" value="lets say Welcome" name="action2">
</form>

PHP

if($_POST["action1"]) {
     echo "Hello";
}
//You can do an else, but I prefer a separate statement
if($_POST["action2"]) {
     echo "Welcome";
}

I hope that you have understand me.

Mr Robot
  • 1,037
  • 9
  • 17
Sweet Life
  • 17
  • 1
  • 1
    This requires two clicks by the user. The OP wants to perform two actions from one click by the user. – PJSimon Jun 04 '17 at 18:20