How can hidden parameters be used to determine which form is being submitted in PHP?
Hidden parameters can be used to determine which form is being submitted in PHP by adding a hidden input field in each form with a unique value. When the form is submitted, the hidden parameter value can be checked in the PHP code to identify which form was submitted. This allows for different actions to be taken based on the form that was submitted.
<form action="process_form.php" method="post">
<input type="hidden" name="form_type" value="form1">
<!-- Other form fields -->
<input type="submit" value="Submit Form 1">
</form>
<form action="process_form.php" method="post">
<input type="hidden" name="form_type" value="form2">
<!-- Other form fields -->
<input type="submit" value="Submit Form 2">
</form>
```
In the PHP code (process_form.php), you can check the hidden parameter value to determine which form was submitted:
```php
if(isset($_POST['form_type'])) {
$formType = $_POST['form_type'];
if($formType == 'form1') {
// Process Form 1
} elseif($formType == 'form2') {
// Process Form 2
}
}