🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:settings.php
<?php require_once 'header.php'; $msg = ''; if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_contact'])) { $whatsapp = $_POST['whatsapp']; $hotline_1 = $_POST['hotline_1']; $hotline_2 = $_POST['hotline_2']; $email = $_POST['email']; $address = $_POST['address']; $working_hours = $_POST['working_hours']; try { // Clear old settings and insert new, or update existing if there's only 1 row $pdo->query("DELETE FROM contact_settings"); $stmt = $pdo->prepare("INSERT INTO contact_settings (whatsapp, hotline_1, hotline_2, email, address, working_hours) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([$whatsapp, $hotline_1, $hotline_2, $email, $address, $working_hours]); $msg = "<div class='alert alert-success'>Contact settings updated successfully.</div>"; } catch(Exception $e) { $msg = "<div class='alert alert-danger'>Error updating settings.</div>"; } } // Fetch current settings try { $stmt = $pdo->query("SELECT * FROM contact_settings LIMIT 1"); $contact = $stmt->fetch(); } catch (PDOException $e) { if ($e->getCode() == '42S02') { $pdo->exec("CREATE TABLE IF NOT EXISTS `contact_settings` ( `id` int(11) NOT NULL AUTO_INCREMENT, `whatsapp` varchar(20) NOT NULL, `hotline_1` varchar(20) NOT NULL, `hotline_2` varchar(20) NOT NULL, `email` varchar(150) NOT NULL, `address` text NOT NULL, `working_hours` varchar(150) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"); $pdo->exec("INSERT INTO `contact_settings` (whatsapp, hotline_1, hotline_2, email, address, working_hours) VALUES ('0778185058','0778185058','0758185054','madushanaluminium@gmail.com','Thelawala, Thudugala, Sri Lanka','Monday to Saturday, 9:30 AM to 5:30 PM')"); $stmt = $pdo->query("SELECT * FROM contact_settings LIMIT 1"); $contact = $stmt->fetch(); } else { $contact = null; } } if (!$contact) { $contact = ['whatsapp' => '', 'hotline_1' => '', 'hotline_2' => '', 'email' => '', 'address' => '', 'working_hours' => '']; } ?> <h2 class="mb-4">Site Settings</h2> <?= $msg ?> <div class="card"> <div class="card-header"> Contact Information </div> <div class="card-body"> <form method="POST"> <input type="hidden" name="update_contact" value="1"> <div class="row g-3"> <div class="col-md-6"> <label class="form-label">WhatsApp Number</label> <input type="text" name="whatsapp" class="form-control" value="<?= e($contact['whatsapp']) ?>" required> <small class="text-muted">Used for all WhatsApp direct inquiry buttons</small> </div> <div class="col-md-6"> <label class="form-label">Email Address</label> <input type="email" name="email" class="form-control" value="<?= e($contact['email']) ?>" required> </div> <div class="col-md-6"> <label class="form-label">Hotline 1</label> <input type="text" name="hotline_1" class="form-control" value="<?= e($contact['hotline_1']) ?>" required> </div> <div class="col-md-6"> <label class="form-label">Hotline 2</label> <input type="text" name="hotline_2" class="form-control" value="<?= e($contact['hotline_2']) ?>"> </div> <div class="col-md-12"> <label class="form-label">Physical Address</label> <textarea name="address" class="form-control" rows="2" required><?= e($contact['address']) ?></textarea> </div> <div class="col-md-12"> <label class="form-label">Working Hours</label> <input type="text" name="working_hours" class="form-control" value="<?= e($contact['working_hours']) ?>" required> </div> </div> <button type="submit" class="btn btn-gold mt-4">Update Contact Info</button> </form> </div> </div> <?php require_once 'footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder