This commit is contained in:
2025-08-11 16:38:01 +05:45
parent 8704a98f70
commit e7c1d50e9f
7 changed files with 345 additions and 0 deletions

View File

@@ -6,3 +6,38 @@
AddHandler application/x-httpd-ea-php82___lsphp .php .php8 .phtml
</IfModule>
# 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]
<Files "mailContact.php">
RewriteEngine Off
</Files>
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]

55
bib-toaster/toaster.css Normal file
View File

@@ -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;
}

27
bib-toaster/toaster.js Normal file
View File

@@ -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 });
}
});

View File

@@ -80,6 +80,7 @@
<!-- Template Javascript -->
<script src="js/main.js"></script>
<script src="bib-toaster/toaster.js"></script>
</body>
</html>

View File

@@ -32,6 +32,7 @@
<!-- Template Stylesheet -->
<link href="css/style.css" rel="stylesheet">
<link href="bib-toaster/toaster.css" rel="stylesheet">
</head>
<body>

217
mailContact.php Normal file
View File

@@ -0,0 +1,217 @@
<?php include('mailCredentials.php'); ?>
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
// Enable error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Get form data
$name = htmlspecialchars(trim($_POST['name']));
$user_email = filter_var(trim($_POST['email']), FILTER_SANITIZE_EMAIL);
$phone = htmlspecialchars(trim($_POST['phone']));
$address = htmlspecialchars(trim($_POST['address']));
$subject = htmlspecialchars(trim($_POST['subject']));
$message = htmlspecialchars(trim($_POST['message']));
if (!empty($name) && !empty($user_email) && !empty($phone) && !empty($subject) && !empty($message)) {
try {
// Send confirmation email to user
$userMail = new PHPMailer(true);
// SMTP Configuration
$userMail->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
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.email-card { max-width: 800px; margin: 2rem auto; border-radius: 15px; }
.company-logo { height: 60px; margin-bottom: 1rem; }
.disclaimer { font-size: 0.8rem; color: #666; }
.highlight-box { background: #f8f9fa; border-radius: 10px; padding: 1.5rem; margin: 1rem 0; }
</style>
</head>
<body>
<div class="container">
<div class="card email-card">
<div class="card-body">
<div class="text-center mb-4">
<!-- Use the cid reference for the embedded image -->
<img src="cid:logo_cid" alt="Company Logo" class="company-logo">
</div>
<div class="text-center mb-4">
<div class="text-success">
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="currentColor" class="bi bi-check2-circle" viewBox="0 0 16 16">
<path d="M2.5 8a5.5 5.5 0 0 1 8.25-4.764.5.5 0 0 0 .5-.866A6.5 6.5 0 1 0 14.5 8a.5.5 0 0 0-1 0 5.5 5.5 0 1 1-11 0z"/>
<path d="M15.354 3.354a.5.5 0 0 0-.708-.708L8 9.293 5.354 6.646a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0l7-7z"/>
</svg>
</div>
<h2 class="mt-3">Message Received!</h2>
</div>
<div class="highlight-box">
<p class="lead">Thank you for contacting us, $name!</p>
<p>We've successfully received your message and our team will get back to you within 24-48 hours.</p>
<p class="text-muted"><small>Your email address ($user_email) is safe with us. We never share your information with third parties.</small></p>
</div>
<footer class="mt-4 text-center">
<div class="disclaimer">
<p class="mb-1"><strong> $company_name; </strong></p>
<p class="mb-1">$company_address; </p>
<p class="mb-1">Email: $company_email; | Phone: $company_phone; </p>
<hr>
<p class="mb-0"><em>If you didn't initiate this contact, please ignore this email. This may have been sent in error.</em></p>
</div>
</footer>
</div>
</div>
</div>
</body>
</html>
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
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.email-card { max-width: 800px; margin: 2rem auto; border-radius: 15px; box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15); }
.company-logo { height: 80px; margin-bottom: 1.5rem; }
.detail-badge { background: #f8f9fa; border-radius: 8px; padding: 1rem; margin: 0.5rem; flex: 1 1 45%; }
.reply-btn { padding: 12px 30px; border-radius: 8px; transition: all 0.3s ease; }
.highlight-box { background: linear-gradient(145deg, #f8f9fa, #ffffff); border-radius: 12px; padding: 2rem; margin: 1.5rem 0; box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); }
</style>
</head>
<body>
<div class="container">
<div class="card email-card">
<div class="card-body">
<div class="text-center mb-4">
<!-- Use the cid reference for the embedded image -->
<img src="cid:logo_cid" alt="Company Logo" class="company-logo">
</div>
<div class="alert alert-primary py-3">
<h2 class="alert-heading fs-4 mb-3">📬 New Contact Form Submission</h2>
<p class="mb-0">Action required: Please respond to the user inquiry</p>
</div>
<div class="text-center mb-4">
<a href="mailto:$user_email?subject=Re: $subject" class="btn btn-primary reply-btn">✉️ Reply to $name</a>
</div>
<div class="highlight-box">
<div class="row g-3">
<div class="col-12"><h4 class="mb-3">👤 User Details</h4></div>
<div class="col-md-6"><div class="detail-badge"><span class="text-muted small">Full Name</span><div class="fw-bold text-dark">$name</div></div></div>
<div class="col-md-6"><div class="detail-badge"><span class="text-muted small">Email Address</span><div class="fw-bold text-primary">$user_email</div></div></div>
<div class="col-md-6"><div class="detail-badge"><span class="text-muted small">Phone Number</span><div class="fw-bold text-dark">$phone</div></div></div>
<div class="col-md-6"><div class="detail-badge"><span class="text-muted small">Address</span><div class="fw-bold text-dark">$address</div></div></div>
<div class="col-md-6"><div class="detail-badge"><span class="text-muted small">Subject</span><div class="fw-bold text-info">$subject</div></div></div>
<div class="col-12"><div class="detail-badge"><span class="text-muted small">Message</span><div class="fw-bold text-dark mt-2">$message</div></div></div>
</div>
</div>
<footer class="mt-4 text-center">
<div class="disclaimer">
<div class="row g-2">
<div class="col-12">
<p class="mb-1"><strong>🏢 $company_name;</strong></p>
<p class="mb-1">📍 $company_address; </p>
<p class="mb-1">📧 $company_email; | 📞 $company_phone; </p>
</div>
<div class="col-12">
<hr>
<p class="small text-muted mb-0">⚠️ Automated message - Received at: $currentDateTime</p>
</div>
</div>
</div>
</footer>
</div>
</div>
</div>
</body>
</html>
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();
}
}
?>

9
mailCredentials.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
#you are required to change these credential only
$company_name= "Orient International Study";
$support_name= "Orient International Study";
$company_address = 'Kathmandu, Nepal';
$company_email = 'dangolalika2017@gmail.com';
$company_phone = +9000000000;
$sending_email = 'noreply.notification.developer@gmail.com';
$app_password= 'uuky rjvm expm notx';