<!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <title>Contact Us – Jobdug.com</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; text-align: center; padding: 20px; } .container { width: 50%; margin: 0 auto; background: white; padding: 20px; border-radius: 5px; box-shadow: 0px 0px 10px #ccc; } input, textarea { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 5px; } button { background: #007bff; color: white; border: none; padding: 10px 20px; cursor: pointer; } button:hover { background: #0056b3; } </style> </head> <body> <div class=”container”> <h2>Contact Us</h2> <form action=”contact.php” method=”POST”> <input type=”text” name=”name” placeholder=”Your Name” required> <input type=”email” name=”email” placeholder=”Your Email” required> <textarea name=”message” rows=”5″ placeholder=”Your Message” required></textarea> <button type=”submit”>Send Message</button> </form> </div> </body> </html>


2. Create a PHP File to Handle Form Submission (contact.php)

phpCopyEdit<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = htmlspecialchars($_POST["name"]);
    $email = htmlspecialchars($_POST["email"]);
    $message = htmlspecialchars($_POST["message"]);

    $to = "jobzfastcom306@gmail.com"; // Your email address
    $subject = "New Contact Message from Jobdug.com";
    $headers = "From: $email" . "\r\n" .
               "Reply-To: $email" . "\r\n" .
               "Content-Type: text/plain; charset=UTF-8";

    $body = "You have received a new message from Jobdug.com:\n\n";
    $body .= "Name: $name\n";
    $body .= "Email: $email\n";
    $body .= "Message:\n$message\n";

    if (mail($to, $subject, $body, $headers)) {
        echo "<script>alert('Your message has been sent successfully!'); window.location.href='contact.html';</script>";
    } else {
        echo "<script>alert('Error sending message. Please try again later.'); window.location.href='contact.html';</script>";
    }
}
?>

How It Works

  1. The user fills out the form on contact.html and clicks Send Message.
  2. The form data is sent to contact.php.
  3. contact.php processes the request and sends an email to jobzfastcom306@gmail.com.
  4. A success or error message is displayed.

Additional Features You Can Add

Database Storage if you want to save user messages.

Google reCAPTCHA for spam protection.

Success/Failure Redirect Page instead of JavaScript alerts.