From e7c1d50e9fdc14bd5d9a4e12c749955073addc84 Mon Sep 17 00:00:00 2001 From: alika Date: Mon, 11 Aug 2025 16:38:01 +0545 Subject: [PATCH] contact --- .htaccess | 35 +++++++ bib-toaster/toaster.css | 55 ++++++++++ bib-toaster/toaster.js | 27 +++++ footer.php | 1 + header.php | 1 + mailContact.php | 217 ++++++++++++++++++++++++++++++++++++++++ mailCredentials.php | 9 ++ 7 files changed, 345 insertions(+) create mode 100644 bib-toaster/toaster.css create mode 100644 bib-toaster/toaster.js create mode 100644 mailContact.php create mode 100644 mailCredentials.php diff --git a/.htaccess b/.htaccess index c994a12..5e1400f 100644 --- a/.htaccess +++ b/.htaccess @@ -6,3 +6,38 @@ AddHandler application/x-httpd-ea-php82___lsphp .php .php8 .phtml # php -- END cPanel-generated handler, do not edit + + +# RewriteEngine On + +# # Remove .php extension from URLs (e.g., /contactt -> contact.php) +# RewriteCond %{REQUEST_FILENAME} !-d +# RewriteCond %{REQUEST_FILENAME}\.php -f +# RewriteRule ^(.*)$ $1.php [L] + +# # Redirect direct access to .php files to clean URLs (optional) +# RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?] [NC] +# RewriteRule ^ /%1 [R=301,L,NE] + + + + + RewriteEngine Off + + + +RewriteEngine On +DirectoryIndex index.php + +# 1. Redirect any index.php request to its directory URL +RewriteCond %{THE_REQUEST} \s/(.*)index\.php[\s?] [NC] +RewriteRule ^(.*)index\.php$ /%1 [R=301,L] + +# 2. Remove .php extension from URLs (e.g., /contactt -> contact.php) +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME}\.php -f +RewriteRule ^(.*)$ $1.php [L] + +# 3. Redirect direct access to .php files to clean URLs (optional) +RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?] [NC] +RewriteRule ^ /%1 [R=301,L,NE] diff --git a/bib-toaster/toaster.css b/bib-toaster/toaster.css new file mode 100644 index 0000000..a726da9 --- /dev/null +++ b/bib-toaster/toaster.css @@ -0,0 +1,55 @@ +.flash-toaster { + position: fixed; + top: 1rem; + right: 1rem; + z-index: 9999; + font-family: sans-serif; +} + +.toast { + display: flex; + align-items: center; + gap: 0.75rem; + min-width: 250px; + max-width: 320px; + padding: 0.75rem 1rem; + border-radius: 4px; + color: #fff; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + transform: translateX(100%); /* start off-screen */ + opacity: 0; + transition: transform 0.4s ease, opacity 0.4s ease; +} + +.toast.show { + transform: translateX(0); + opacity: 1; +} + +/* Status colors */ +.toast--success { + background: #198754; +} +.toast--error { + background: #dc3545; +} +.toast--warning { + background: #ffc107; + color: #000; +} + +/* Close button */ +.toast__close { + background: none; + border: none; + color: inherit; + font-size: 1.2rem; + line-height: 1; + cursor: pointer; +} + +/* Hide animation */ +.toast.hide { + transform: translateX(100%); + opacity: 0; +} diff --git a/bib-toaster/toaster.js b/bib-toaster/toaster.js new file mode 100644 index 0000000..437504d --- /dev/null +++ b/bib-toaster/toaster.js @@ -0,0 +1,27 @@ + +document.addEventListener('DOMContentLoaded', () => { + const toast = document.getElementById('flashToast'); + if (!toast) return; + + // Show it + requestAnimationFrame(() => { + toast.classList.add('show'); + }); + + // Close on [×] + toast.querySelector('.toast__close').addEventListener('click', () => { + hideToast(); + }); + + // Auto-hide after 3s + const hideTimeout = setTimeout(hideToast, 3000); + + function hideToast(){ + clearTimeout(hideTimeout); + toast.classList.add('hide'); + // Remove from DOM after transition + toast.addEventListener('transitionend', () => { + toast.remove(); + }, { once: true }); + } +}); diff --git a/footer.php b/footer.php index 6d97948..46ad4c3 100644 --- a/footer.php +++ b/footer.php @@ -80,6 +80,7 @@ + \ No newline at end of file diff --git a/header.php b/header.php index 5ed9214..b0fb261 100644 --- a/header.php +++ b/header.php @@ -32,6 +32,7 @@ + diff --git a/mailContact.php b/mailContact.php new file mode 100644 index 0000000..03e05a7 --- /dev/null +++ b/mailContact.php @@ -0,0 +1,217 @@ + +isSMTP(); + $userMail->Host = 'smtp.gmail.com'; + $userMail->SMTPAuth = true; + $userMail->Username = $sending_email; + $userMail->Password = $app_password; + $userMail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + $userMail->Port = 587; + + // User Email Configuration + $userMail->setFrom($sending_email, $support_name); + $userMail->addAddress($user_email); + $userMail->isHTML(true); + $userMail->Subject = "Thank you for contacting " . $support_name; + + // Embed logo + $userMail->addEmbeddedImage('img/Orient.png', 'logo_cid'); + + // User Email Template + $userMail->Body = << + + + + + + +
+ +
+ + +HTML; + + // Send admin email + $adminMail = new PHPMailer(true); + $adminMail->isSMTP(); + $adminMail->Host = 'smtp.gmail.com'; + $adminMail->SMTPAuth = true; + $adminMail->Username = $sending_email; + $adminMail->Password = $app_password; + $adminMail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + $adminMail->Port = 587; + + $adminMail->setFrom($sending_email, $support_name); + $adminMail->addAddress($company_email); + $adminMail->addReplyTo($user_email, $name); + $adminMail->isHTML(true); + $adminMail->Subject = "New Contact: $subject"; + + // Embed logo for admin email + $adminMail->addEmbeddedImage('img/Orient.png', 'logo_cid'); + + // Admin Email Template + $currentDateTime = date('Y-m-d H:i:s'); + $adminMail->Body = << + + + + + + +
+ +
+ + +HTML; + + // Send emails + $userMail->send(); + $adminMail->send(); + + // Redirect to prevent resubmission + header("Location: contact.php?status=success"); + exit(); + + } catch (Exception $e) { + $errorMessage = urlencode($e->getMessage()); // Encode for safe URL usage + header("Location: contact.php?status=error&message=$errorMessage"); + exit(); + } + + } else { + header("Location: contact.php?status=missing_fields"); + exit(); + } +} + +// Include header after potential redirects +// include('header.php'); + +// Handle status messages +if (isset($_GET['status'])) { + switch ($_GET['status']) { + case 'success': + // After successful email sending + header("Location: contact.php?status=success"); + exit(); + + case 'error': + header("Location: contact.php?status=error"); + exit(); + + case 'missing_fields': + header("Location: contact.php?status=missing_fields"); + exit(); + } +} +?> diff --git a/mailCredentials.php b/mailCredentials.php new file mode 100644 index 0000000..7026c07 --- /dev/null +++ b/mailCredentials.php @@ -0,0 +1,9 @@ +