The HTML Form action attribute is used to define where the form data will be sent to the server after the form is submitted.

File structure

To understand the form action before you need to see our project structure

┣ action_page.php
┗ index.html


<!DOCTYPE html>
        <form action="action_page.php">
            <label for="fname">First name:</label><br>
            <input type="text" id="fname" name="fname" value="John"><br>
            <label for="lname">Last name:</label><br>
            <input type="text" id="lname" name="lname" value="Doe"><br><br>
            <input type="submit" value="Submit">



if (isset($_POST['fname'])) {
    echo "First Name is: " . $_POST['fname'] . "<br>";
    echo "Last Name is: " . $_POST['lname'] . "<br>";

When you click the submit button you will see the first name and last name from the user input

Try it Yourself