<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $to = "taufiq00321@gmail.com";
    $name = strip_tags(trim($_POST["name"]));
    $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
    $subject = strip_tags(trim($_POST["subject"]));
    $message = trim($_POST["message"]);

    $full_message = "Name: $name\nEmail: $email\n\nMessage:\n$message";
    $headers = "From: $name <$email>";

    if (mail($to, $subject, $full_message, $headers)) {
        echo "success";
    } else {
        echo "error";
    }
}
?>
