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 = "
Contact settings updated successfully.
";
} catch(Exception $e) {
$msg = "Error updating settings.
";
}
}
// 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' => ''];
}
?>
Site Settings
= $msg ?>