<?php
require_once __DIR__ . '/includes/functions.php';
$successMessage = null;
$errors = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!csrfVerify($_POST['csrf_token'] ?? null)) {
$errors[] = 'Your session expired — please try submitting again.';
} elseif (!empty($_POST['company_website'])) {
// Honeypot tripped — silently pretend success to the bot, do nothing.
$successMessage = 'Thanks! Your message has been sent — we will get back to you shortly.';
} elseif (!rateLimitCheck('contact_form', 5, 60)) {
$errors[] = 'Too many submissions — please wait a minute and try again.';
} else {
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$phone = trim($_POST['phone'] ?? '');
$subject = trim($_POST['subject'] ?? '');
$message = trim($_POST['message'] ?? '');
if ($name === '') $errors[] = 'Please enter your name.';
if ($email === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) $errors[] = 'Please enter a valid email address.';
if ($message === '') $errors[] = 'Please enter a message.';
if (!$errors) {
$stmt = db()->prepare('INSERT INTO contact_messages (name, email, phone, subject, message) VALUES (?, ?, ?, ?, ?)');
$stmt->execute([$name, $email, $phone ?: null, $subject ?: null, $message]);
$successMessage = 'Thanks! Your message has been sent — we will get back to you shortly.';
}
}
}
$seo = getSeo('contact');
$activeNav = 'contact';
require __DIR__ . '/includes/header.php';
?>
<body data-page="contact" class="antialiased text-gray-800">
<section class="hero-gradient py-16">
<div class="max-w-7xl mx-auto px-5 lg:px-8">
<p class="text-sm text-gray-500 mb-3"><a href="index.php" class="hover:text-primary">Home</a> <i class="bi bi-chevron-right text-xs mx-1"></i> Contact Us</p>
<h1 class="font-heading text-4xl font-bold">Get In Touch</h1>
<p class="text-gray-600 mt-3 max-w-2xl">Have a question about TallyPrime or need a free consultation? We'd love to hear from you.</p>
</div>
</section>
<section class="py-16 max-w-7xl mx-auto px-5 lg:px-8">
<div class="grid sm:grid-cols-2 lg:grid-cols-4 gap-6">
<div class="soft-card p-7 reveal">
<div class="icon-badge mb-5"><i class="bi bi-geo-alt-fill"></i></div>
<h3 class="font-heading font-semibold mb-2">Our Address</h3>
<p class="text-sm text-gray-500"><?= e($settings['address'] ?? '') ?></p>
</div>
<div class="soft-card p-7 reveal">
<div class="icon-badge mb-5"><i class="bi bi-telephone-fill"></i></div>
<h3 class="font-heading font-semibold mb-2">Call Us</h3>
<p class="text-sm text-gray-500"><?= e($settings['phone'] ?? '') ?></p>
</div>
<div class="soft-card p-7 reveal">
<div class="icon-badge mb-5"><i class="bi bi-envelope-fill"></i></div>
<h3 class="font-heading font-semibold mb-2">Email Us</h3>
<p class="text-sm text-gray-500"><?= e($settings['email'] ?? '') ?></p>
</div>
<div class="soft-card p-7 reveal">
<div class="icon-badge mb-5"><i class="bi bi-clock-fill"></i></div>
<h3 class="font-heading font-semibold mb-2">Office Hours</h3>
<p class="text-sm text-gray-500">Sun – Fri: 10:00 AM – 6:00 PM<br />Saturday: Closed</p>
</div>
</div>
</section>
<section class="py-10 max-w-7xl mx-auto px-5 lg:px-8 grid lg:grid-cols-2 gap-10">
<div class="soft-card p-8 reveal">
<h2 class="font-heading text-2xl font-bold mb-2">Send Us a Message</h2>
<p class="text-sm text-gray-500 mb-6">Fill out the form and our team will respond within 24 hours.</p>
<?php if ($successMessage): ?>
<p class="text-sm text-green-600 mb-4 text-center"><i class="bi bi-check-circle-fill"></i> <?= e($successMessage) ?></p>
<?php endif; ?>
<?php if ($errors): ?>
<div class="text-sm text-red-600 mb-4">
<?php foreach ($errors as $err): ?><p><i class="bi bi-exclamation-circle-fill"></i> <?= e($err) ?></p><?php endforeach; ?>
</div>
<?php endif; ?>
<form method="post" action="contact.php#send-message" class="space-y-4">
<input type="hidden" name="csrf_token" value="<?= e(csrfToken()) ?>" />
<input type="text" name="company_website" class="hidden" tabindex="-1" autocomplete="off" />
<div class="grid sm:grid-cols-2 gap-4">
<input type="text" name="name" required placeholder="Full Name" class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary text-sm" />
<input type="tel" name="phone" placeholder="Phone Number" class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary text-sm" />
</div>
<input type="email" name="email" required placeholder="Email Address" class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary text-sm" />
<select name="subject" class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary text-sm text-gray-500">
<option value="">Select an Inquiry Type</option>
<option>Tally Software Sales</option>
<option>Implementation</option>
<option>Customization</option>
<option>Training</option>
<option>Support / AMC</option>
<option>Other</option>
</select>
<textarea name="message" rows="5" required placeholder="Your Message" class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary text-sm"></textarea>
<button class="btn-primary-brand w-full py-3.5 rounded-lg font-semibold">Send Message</button>
</form>
</div>
<div class="reveal">
<div class="soft-card overflow-hidden h-72 lg:h-[calc(50%-1.25rem)] mb-5">
<iframe
src="<?= e($settings['map_embed_url'] ?? 'https://www.google.com/maps?q=Kathmandu,Nepal&output=embed') ?>"
width="100%" height="100%" style="border:0;" allowfullscreen="" loading="lazy"
referrerpolicy="no-referrer-when-downgrade" title="PIMS Nepal Office Location">
</iframe>
</div>
<div class="soft-card p-7">
<h3 class="font-heading font-semibold mb-4">Quick Contact</h3>
<div class="space-y-3 text-sm">
<?php if (!empty($settings['phone'])): ?><a href="tel:<?= e($settings['phone']) ?>" class="flex items-center gap-3 text-gray-600 hover:text-primary"><i class="bi bi-telephone-fill text-primary"></i> <?= e($settings['phone']) ?></a><?php endif; ?>
<?php if (!empty($settings['email'])): ?><a href="mailto:<?= e($settings['email']) ?>" class="flex items-center gap-3 text-gray-600 hover:text-primary"><i class="bi bi-envelope-fill text-primary"></i> <?= e($settings['email']) ?></a><?php endif; ?>
<a id="whatsapp-quick-link" href="#" target="_blank" rel="noopener" class="flex items-center gap-3 text-gray-600 hover:text-primary"><i class="bi bi-whatsapp text-primary"></i> Chat on WhatsApp</a>
</div>
</div>
</div>
</section>
<?php $bridgeSections = ['site']; require __DIR__ . '/includes/footer.php'; ?>