<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    $name = htmlspecialchars($_POST['name']);
    $email = htmlspecialchars($_POST['email']);
    $message = htmlspecialchars($_POST['message']);

    $to = "your@email.com"; // CHANGE THIS TO YOUR EMAIL
    $subject = "New Contact Message";

    $body = "
    You have received a new message:

    Name: $name
    Email: $email

    Message:
    $message
    ";

    $headers = "From: no-reply@yoursite.com\r\n";
    $headers .= "Reply-To: $email\r\n";

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