<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Stylish Contact Form</title>
<style>
* {
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.contact-form {
background-color: #fff;
padding: 30px 40px;
border-radius: 15px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
width: 100%;
max-width: 400px;
}
.contact-form h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.contact-form input,
.contact-form textarea {
width: 100%;
padding: 12px 15px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 8px;
font-size: 16px;
transition: border 0.3s ease;
}
.contact-form input:focus,
.contact-form textarea:focus {
border-color: #2575fc;
outline: none;
}
.contact-form button {
width: 100%;
padding: 12px;
background-color: #2575fc;
color: white;
border: none;
font-size: 16px;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.contact-form button:hover {
background-color: #1b5bd8;
}
</style>
</head>
<body>
<form class="contact-form" action="send.php" method="post">
<h2>Contact Us</h2>
<input type="text" name="name" placeholder="Your Name" required>
<input type="email" name="email" placeholder="Your Email" required>
<textarea name="message" placeholder="Your Message" rows="5"></textarea>
<button type="submit">Send Message</button>
</form>
</body>
</html>
send.php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST["name"]);
$email = htmlspecialchars($_POST["email"]);
$message = htmlspecialchars($_POST["message"]);
$to = "youremail@example.com";
$subject = "New Contact Message";
$body = "From: $name\nEmail: $email\nMessage:\n$message";
if (mail($to, $subject, $body)) {
echo "Message sent successfully!";
} else {
echo "Failed to send message.";
}
}
?>