🤩 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 // admin/settings.php require_once '../includes/db.php'; require_once '../includes/functions.php'; $error = ''; $success = ''; try { $settings = get_admin_settings($pdo); } catch (PDOException $e) { die("Database lookup error: " . $e->getMessage()); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $company_name = trim($_POST['company_name'] ?? ''); $admin_whatsapp = trim($_POST['admin_whatsapp'] ?? ''); $admin_email = trim($_POST['admin_email'] ?? ''); $admin_address = trim($_POST['admin_address'] ?? ''); // Form validations if (empty($company_name) || empty($admin_whatsapp) || empty($admin_email) || empty($admin_address)) { $error = 'All fields are required to update settings.'; } elseif (!filter_var($admin_email, FILTER_VALIDATE_EMAIL)) { $error = 'Please enter a valid email address.'; } else { try { $sql = "UPDATE settings SET company_name = :company_name, admin_whatsapp = :admin_whatsapp, admin_email = :admin_email, admin_address = :admin_address WHERE id = 1"; $stmt = $pdo->prepare($sql); $stmt->execute([ ':company_name' => $company_name, ':admin_whatsapp' => $admin_whatsapp, ':admin_email' => $admin_email, ':admin_address' => $admin_address ]); $success = 'Company settings updated successfully!'; // Reload settings $settings = get_admin_settings($pdo); } catch (PDOException $e) { $error = 'Failed to save settings: ' . $e->getMessage(); } } } include '../includes/admin_header.php'; ?> <?php if (!empty($error)): ?> <div class="alert alert-danger border-0 shadow-sm mb-4"><i class="fas fa-times-circle me-2"></i><?php echo $error; ?></div> <?php endif; ?> <?php if (!empty($success)): ?> <div class="alert alert-success border-0 shadow-sm mb-4"><i class="fas fa-check-circle me-2"></i><?php echo $success; ?></div> <?php endif; ?> <div class="row"> <div class="col-lg-8"> <div class="card premium-card"> <div class="card-header-royal"> <h5 class="mb-0"><i class="fas fa-sliders-h me-2"></i>Global Business Settings</h5> <small class="text-white-50">Updates here apply immediately to customer-facing order links and generated emails.</small> </div> <div class="card-body p-4 p-md-5"> <form method="POST" action="settings.php"> <div class="mb-4"> <label for="company_name" class="form-label">Company Name</label> <div class="input-group"> <span class="input-group-text"><i class="fas fa-building text-muted"></i></span> <input type="text" class="form-control" id="company_name" name="company_name" required value="<?php echo s($settings['company_name'] ?? ''); ?>" placeholder="Royal Curtain"> </div> </div> <div class="mb-4"> <label for="admin_whatsapp" class="form-label">Admin WhatsApp Number</label> <div class="input-group"> <span class="input-group-text bg-success-subtle text-success"><i class="fa-brands fa-whatsapp fa-lg"></i></span> <input type="text" class="form-control" id="admin_whatsapp" name="admin_whatsapp" required value="<?php echo s($settings['admin_whatsapp'] ?? ''); ?>" placeholder="e.g. 94771234567 (with country code, no + or spaces)"> </div> <div class="form-text small text-muted"> <i class="fas fa-info-circle me-1"></i>Ensure to include country code (e.g. 94 for Sri Lanka) with no prefix "+" or spaces. </div> </div> <div class="mb-4"> <label for="admin_email" class="form-label">Contact Email Address</label> <div class="input-group"> <span class="input-group-text"><i class="fas fa-envelope text-muted"></i></span> <input type="email" class="form-control" id="admin_email" name="admin_email" required value="<?php echo s($settings['admin_email'] ?? ''); ?>" placeholder="sales@royalcurtain.com"> </div> </div> <div class="mb-4"> <label for="admin_address" class="form-label">Showroom / Fitting Address</label> <textarea class="form-control" id="admin_address" name="admin_address" rows="4" required placeholder="Enter the company location address"><?php echo s($settings['admin_address'] ?? ''); ?></textarea> </div> <div class="d-grid mt-4"> <button type="submit" class="btn btn-royal py-3 fw-bold text-uppercase"> <i class="fas fa-save me-2"></i>Save Business Settings </button> </div> </form> </div> </div> </div> <!-- Info / Help Panel --> <div class="col-lg-4"> <div class="card premium-card bg-light border-0 shadow-sm"> <div class="card-body p-4"> <h6 class="text-royal fw-bold mb-3"><i class="fas fa-question-circle me-2"></i>Setting Up WhatsApp</h6> <p class="small text-muted">The Admin WhatsApp Number is used to generate direct links for your clients. When they click the final <strong>Order via WhatsApp</strong> button on the checkout page, their mobile application will open a direct chat window with this number, prefilling the structured order request.</p> <div class="alert alert-warning border-0 p-3 mb-0 small"> <i class="fas fa-exclamation-triangle text-warning me-2"></i> <strong>Format Rule:</strong> Do not add symbols like <code>+</code>, <code>( )</code>, or dashes <code>-</code> in the WhatsApp number field. E.g., Use <code>94771234567</code> instead of <code>+94 (77) 123-4567</code>. </div> </div> </div> </div> </div> <?php include '../includes/admin_footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder