-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.php
More file actions
204 lines (165 loc) · 7.79 KB
/
contact.php
File metadata and controls
204 lines (165 loc) · 7.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
require 'admin/db.php';
// Process form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$message = trim($_POST['message']);
// Validate inputs
if ($name && $email && $message) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
// Insert into the database
$stmt = $pdo->prepare("INSERT INTO contact_messages (name, email, message) VALUES (?, ?, ?)");
if ($stmt->execute([$name, $email, $message])) {
$success = "Thank you! Your message has been sent.";
} else {
$error = "Sorry, something went wrong. Please try again.";
}
} else {
$error = "Invalid email format.";
}
} else {
$error = "Please fill in all fields.";
}
}
// Fetch settings from the database
$stmt = $pdo->query("SELECT * FROM settings LIMIT 1");
$settings = $stmt->fetch();
// Fetch contact information from the database
$stmt = $pdo->query("SELECT * FROM contact_info LIMIT 1");
$contact_info = $stmt->fetch();
$logo_path = $settings['logo_path'] ?? '/admin/uploads/default-logo.png';
$google_analytics_code = $settings['google_analytics_code'] ?? '';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Us</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<!-- Google Analytics Code -->
<?php if (!empty($google_analytics_code)): ?>
<?php echo $google_analytics_code; ?>
<?php endif; ?>
<!-- Favicon -->
<link rel="icon" href="<?php echo htmlspecialchars($settings['favicon_path']); ?>" type="image/x-icon">
<style>
/* Footer Styling */
footer {
background-color: #333;
color: white;
padding: 15px;
text-align: center;
font-size: 0.9rem;
}
footer a {
color: #ccc;
text-decoration: none;
margin: 0 5px;
}
footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="#">
<img src="<?php echo htmlspecialchars($logo_path); ?>" height="70px" width="210px" alt="Logo"> <!-- Display logo from settings -->
<?php echo htmlspecialchars($header_name); ?>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
<li class="nav-item"><a class="nav-link" href="/page.php?slug=about">About Us</a></li>
<li class="nav-item"><a class="nav-link" href="/page.php?slug=privacy">Privacy</a></li>
<li class="nav-item"><a class="nav-link" href="/page.php?slug=terms">Terms</a></li>
<li class="nav-item"><a class="nav-link" href="/contact.php">Contact Us</a></li>
</ul>
</div>
</nav>
<div class="container mt-5">
<div class="mb-4">
<p><strong>Email:</strong> <?php echo htmlspecialchars($contact_info['email'] ?? 'Not available'); ?></p>
<p><strong>Phone:</strong> <?php echo htmlspecialchars($contact_info['phone'] ?? 'Not available'); ?></p>
<p><strong>Address:</strong> <?php echo nl2br(htmlspecialchars($contact_info['address'] ?? 'Not available')); ?></p>
</div>
<h1>Contact Us</h1>
<?php if (isset($success)): ?>
<div class="alert alert-success"><?php echo htmlspecialchars($success); ?></div>
<?php elseif (isset($error)): ?>
<div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div>
<?php endif; ?>
<form action="contact.php" method="post">
<div class="form-group">
<label for="name">Your Name</label>
<input type="text" name="name" id="name" class="form-control" required>
</div>
<div class="form-group">
<label for="email">Your Email</label>
<input type="email" name="email" id="email" class="form-control" required>
</div>
<div class="form-group">
<label for="message">Your Message</label>
<textarea name="message" id="message" rows="5" class="form-control" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Send Message</button>
</form>
</div>
<br>
<!-- Left-Aligned Modern Footer -->
<footer class="footer bg-dark text-white py-5">
<div class="container">
<div class="row">
<!-- About Us Section -->
<div class="col-md-4 mb-4 text-left">
<h5 class="text-uppercase">About Us</h5>
<p class="text-muted">
<?php echo htmlspecialchars($contact_info['faboutus'] ?? 'Not available'); ?>
</p>
</div>
<!-- Quick Links Section -->
<div class="col-md-4 mb-4 text-left">
<h5 class="text-uppercase">Quick Links</h5>
<ul class="list-unstyled">
<li><a href="/index.php" class="text-muted">Home</a></li>
<li><a href="/page.php?slug=about" class="text-muted">About Us</a></li>
<li><a href="/page.php?slug=privacy" class="text-muted">Privacy Policy</a></li>
<li><a href="/page.php?slug=terms" class="text-muted">Terms of Service</a></li>
<li><a href="/contact.php" class="text-muted">Contact Us</a></li>
</ul>
</div>
<!-- Contact Section -->
<div class="col-md-4 mb-4 text-left">
<h5 class="text-uppercase">Contact Us</h5>
<ul class="list-unstyled text-muted">
<li><strong>Email:</strong> <?php echo htmlspecialchars($contact_info['email'] ?? 'Not available'); ?></li>
<li><strong>Phone:</strong><?php echo htmlspecialchars($contact_info['phone'] ?? 'Not available'); ?></li>
<li><strong>Address:</strong> <?php echo nl2br(htmlspecialchars($contact_info['address'] ?? 'Not available')); ?></li>
</ul>
<!-- Social Media Icons -->
<div class="social-links mt-3">
<a href="#" class="text-white mr-3"><i class="fab fa-facebook fa-lg"></i></a>
<a href="#" class="text-white mr-3"><i class="fab fa-twitter fa-lg"></i></a>
<a href="#" class="text-white mr-3"><i class="fab fa-instagram fa-lg"></i></a>
<a href="#" class="text-white mr-3"><i class="fab fa-linkedin fa-lg"></i></a>
</div>
</div>
</div>
</div>
</div>
</footer>
<!-- Footer Section -->
<footer class="footer">
<p>© <?php echo date('Y'); ?> <?php echo htmlspecialchars($header_name); ?> | <a href="/page.php?slug=privacy">Privacy Policy</a> | <a href="/page.php?slug=terms">Terms of Service</a></p>
</footer>
<!-- Include Bootstrap JS and its dependencies -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.4.4/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>