<?php
/*
Template Name: Contact Form
*/

get_header(); // Header include karna

if ($_SERVER[“REQUEST_METHOD”] == “POST”) {
$name = sanitize_text_field($_POST[‘name’]);
$email = sanitize_email($_POST[’email’]);
$message = sanitize_textarea_field($_POST[‘message’]);

$to = ‘recipient@example.com’; // Apna email yahan daalein
$subject = ‘New Message from Contact Form’;
$body = “Name: $name\nEmail: $email\nMessage:\n$message”;
$headers = “From: $email”;

if (mail($to, $subject, $body, $headers)) {
echo “Mail sent successfully!”;
} else {
echo “Failed to send mail.”;
}
}
?>

<form method=”POST” action=””>
<label for=”name”>Name:</label>
<input type=”text” id=”name” name=”name” required>

<label for=”email”>Email:</label>
<input type=”email” id=”email” name=”email” required>

<label for=”message”>Message:</label>
<textarea id=”message” name=”message” required></textarea>

<button type=”submit”>Send</button>
</form>

<?php get_footer(); // Footer include karna ?>