✅ 1. HTML Form (contact.html)

 <!DOCTYPE html>

<html>

<head>

  <title>Contact Form</title>

</head>

<body>


  <h2>Contact Us</h2>


  <form action = "submit_form.php" method = "post">

    <label for = "name"> Full Name: </label> <br>

    <input type = "text" id = "name" name = "name" required> <br> <br>


    <label for = "email"> Email Address: </label> <br>

    <input type = "email" id = "email" name = "email" required> <br> <br>


    <label for = "message"> Message: </label> <br>

    <textarea id = "message" name = "message" rows = "5" cols = "30" required> </textarea> <br> <br>


    <input type = "submit" value = "Submit">

  </form>


</body>

</html>

PHP 2. PHP File (submit_form.php)

<?php
// Check if the form is submitted
if ($ _SERVER ["REQUEST_METHOD"] == "POST") {
    
    // Collect and sanitize input
    $ name = htmlspecialchars ($ _ POST ["name"]);
    $ email = htmlspecialchars ($ _ POST ["email"]);
    $ message = htmlspecialchars ($ _ POST ["message"]);

    // Display the result (you can also save to a database or send via email)
    echo "<h2> Form Submitted Successfully! </h2>";
    echo "<p> <strong> Name: </strong>". $ name. "</p>";
    echo "<p> <strong> Email: </strong>". $ email. "</p>";
    echo "<p> <strong> Message: </strong>". nl2br ($ message). "</p>";
} else {
    echo "Invalid request method.";
}
?>

អត្ថបទបន្ទាប់ អត្ថបទមុន