How to use multiple HTML form and only one PHP engine

form.html

<html>
<body>
  
<form action="engine.php?action=firstEvent" method="post">
    Text: <input type="text" name="content"><br/>
    <input type="submit" value="Insert Event">
</form>

<form action="engine.php?action=secondEvent" method="post">
    Text: <input type="text" name="content"><br/>
    <input type="submit" value="Insert Event">
</form>

<form action="engine.php?action=thirdEvent" method="post">
    Text: <input type="text" name="content"><br/>
    <input type="submit" value="Insert Event">
</form>
  
</body>
</html>

engine.php

<?php
// Get HTML form data
if($_GET['action'] == 'firstEvent'){
    echo 'firstEvent <br>';
    $content = $_REQUEST['content']; 
    echo $content;
}

if($_GET['action'] == 'secondEvent'){
    echo 'secondEvent <br>';
    $content = $_REQUEST['content']; 
    echo $content;
}

if($_GET['action'] == 'thirdEvent'){
    echo 'thirdEvent <br>';
    $content = $_REQUEST['content']; 
    echo $content;
}
?>

Notice that the HTML form can send:
– engine.php?action=firstEvent
– engine.php?action=secondtEvent
– engine.php?action=thirdEvent

The PHP script makes different actions if it gets:
– GET[‘action’] == ‘firstEvent’
– GET[‘action’] == ‘secondEvent’
– GET[‘action’] == ‘thirdEvent’