PHP具有单个动作的多个表单

I've multiple forms with a single action, a single php page that gets called by all the forms.

How can I differentiate which form was sent to the php page?

Using a different unique input type="hidden" for each form.

HTML:

<input type="hidden" name="form_id" value="1">
<input type="hidden" name="form_id" value="2">

PHP:

$myform = $_POST["form_id"];

You can also use the submit button but note that the "value" parameter is what gets displayed to the user so you won't be able to modify it (assuming you want the same text to be displayed on every button).

<input type="submit" name="action" value="the user saw this">

PHP:

$_POST["action"] // -> "the user saw this";

Give each submitbutton an other name or put a with different values in each form.

You can detect this from the submit button itself too, if submit has different values like:

update name, update profile, delete users...

Add a hidden field (action or the like) to each field, then check for it.

<form id="num1">
    <input type="hidden" name="action" value="first_action" />
</form>

...and the check:

<?php

    if(!empty($_REQUEST['action']) {
        switch($_REQUEST['action']) {
            case 'first_action':
                // first action code

                break;
        }
    }

?>

On the submit button for each form, use different names. Something like:

<input type="submit" name="submit_1" value="Submit" />
<input type="submit" name="submit_2" value="Submit" />
<input type="submit" name="submit_3" value="Submit" />
...

Then on your PHP, you'll have:

$_POST["submit_1"]
$_POST["submit_2"]
$_POST["submit_3"]