if ($_SERVER["REQUEST_METHOD"] == "POST") { $formName = $_POST["formName"]; if ($formName == "login") { // handle login form submission } else if ($formName == "signup") { // handle signup form submission } }
function submitForm($form) { $formName = $form->getName(); if ($formName == "login") { // handle login form submission } else if ($formName == "signup") { // handle signup form submission } }In this example, we pass the form object to a JavaScript function when it is submitted. The function then calls the PHP function with the form object as an argument. The package/library used for this function would be dependent on the PHP framework or library being used. This function is commonly used in web development and is likely to be included in many PHP libraries or frameworks.