<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.container {
max-width: 600px;
width: 100%;
}
.contact-form {
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
padding: 40px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.form-header {
text-align: center;
margin-bottom: 30px;
}
.form-header h2 {
color: #333;
font-size: 2rem;
margin-bottom: 10px;
}
.form-group {
margin-bottom: 25px;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 600;
}
.form-group input, .form-group textarea {
width: 100%;
padding: 14px 18px;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 1rem;
transition: all 0.3s ease;
}
.form-group input:focus, .form-group textarea:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}
.submit-btn {
width: 100%;
padding: 16px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 10px;
font-size: 1.1rem;
cursor: pointer;
transition: transform 0.3s ease;
}
.submit-btn:hover {
transform: translateY(-2px);
}
.form-header {
text-align: center;
margin-bottom: 30px;
}
.form-header h2 {
color: #333;
font-size: 2rem;
margin-bottom: 10px;
}
.form-header p {
color: #666;
}
.form-group {
margin-bottom: 25px;
}
.form-group label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 600;
font-size: 0.95rem;
}
.form-group input,
.form-group textarea {
width: 100%;
padding: 14px 18px 14px 50px;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 1rem;
font-family: inherit;
transition: all 0.3s ease;
background: white;
}
.input-wrapper {
position: relative;
}
.input-icon {
position: absolute;
left: 18px;
top: 50%;
transform: translateY(-50%);
color: #999;
font-size: 1.2rem;
transition: color 0.3s ease;
}
.input-wrapper input:focus ~ .input-icon,
.input-wrapper textarea:focus ~ .input-icon {
color: #667eea;
}
.form-group input:focus,
.form-group textarea:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
color: #aaa;
}
.form-group textarea {
resize: vertical;
min-height: 120px;
}
.form-group input.error,
.form-group textarea.error {
border-color: #e74c3c;
}
.error-message {
color: #e74c3c;
font-size: 0.85rem;
margin-top: 5px;
display: none;
}
.submit-btn {
width: 100%;
padding: 16px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 10px;
font-size: 1.1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
display: flex;
align-items: center;
justify-content: center;
}
.submit-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}
.submit-btn:active {
transform: translateY(0);
}
.submit-btn:hover span:last-child {
transform: translateX(4px);
display: inline-block;
}
.submit-btn span {
transition: transform 0.3s ease;
}
.success-message {
background: #2ecc71;
color: white;
padding: 15px;
border-radius: 10px;
margin-bottom: 20px;
display: none;
}
</style>
</head>
<body>
<div class="contact-form">
<div class="form-header">
<h2>Get In Touch</h2>
<p>Fill out the form below and we'll get back to you shortly</p>
</div>
<form id="contactForm" method="POST" action="process_contact.php">
<div class="form-group">
<label for="name">Full Name *</label>
<div class="input-wrapper">
<input type="text" id="name" name="name" placeholder="John Doe" required>
<span class="input-icon">👤</span>
</div>
<span class="error-message" id="nameError">Please enter your name</span>
</div>
<div class="form-group">
<label for="email">Email Address *</label>
<div class="input-wrapper">
<input type="email" id="email" name="email" placeholder="john@example.com" required>
<span class="input-icon">✉️</span>
</div>
<span class="error-message" id="emailError">Please enter a valid email</span>
</div>
<div class="form-group">
<label for="phone">Phone Number</label>
<div class="input-wrapper">
<input type="tel" id="phone" name="phone" placeholder="0400 000 000">
<span class="input-icon">📞</span>
</div>
</div>
<div class="form-group">
<label for="message">Message *</label>
<div class="input-wrapper">
<textarea id="message" name="message" placeholder="Tell us more about your inquiry..." required></textarea>
</div>
<span class="error-message" id="messageError">Please enter your message</span>
</div>
<button type="submit" class="submit-btn">
Send Message
<span style="margin-left: 8px;">→</span>
</button>
</form>
<div class="success-message" id="successMessage">
Thank you! Your message has been sent successfully.
</div>
</div>
<script>
document.getElementById('contactForm').addEventListener('submit', function(e) {
e.preventDefault();
document.querySelectorAll('.error-message').forEach(el => el.style.display = 'none');
document.querySelectorAll('.error').forEach(el => el.classList.remove('error'));
let isValid = true;
const name = document.getElementById('name');
const email = document.getElementById('email');
const message = document.getElementById('message');
if (!name.value.trim()) {
name.classList.add('error');
document.getElementById('nameError').style.display = 'block';
isValid = false;
}
if (!email.value.trim() || !email.value.includes('@')) {
email.classList.add('error');
document.getElementById('emailError').style.display = 'block';
isValid = false;
}
if (!message.value.trim()) {
message.classList.add('error');
document.getElementById('messageError').style.display = 'block';
isValid = false;
}
if (isValid) {
const formData = new FormData(this);
fetch('process_contact.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('successMessage').style.display = 'block';
this.reset();
setTimeout(() => {
document.getElementById('successMessage').style.display = 'none';
}, 5000);
}
})
.catch(error => console.error('Error:', error));
}
});
</script>
</body>
</html>