i have header and footer files in includes folder, and i need to add them in this codes (<?php
include('../db_connect.php');
// Handle adding a new service
if (isset(_POST['add_service'])) {
service_name = POST[′serviceservice_cost = service_description = $_POST['service_description']; // New variable for description
Certainly! Below is the complete PHP code integrated with your header.php and footer.php files located in the includes folder. The design has been enhanced using CSS variables for a modern and cohesive look.
Directory Structure Assumption
code
your_project/
│
├── includes/
│ ├── header.php
│ └── footer.php
│
├── db_connect.php
└── manage_services.php (the main file)
Header: The header.php is included within the <head> section to allow it to add any necessary meta tags, styles, or scripts. If your header.php contains elements like the navigation bar, you might want to include it right after the <body> tag. Adjust accordingly based on your header.php content.
Footer: The footer.php is included just before the closing </body> tag to ensure it appears at the bottom of the page.
CSS Enhancements:
CSS Variables: Defined using :root for easy customization and to maintain consistency across the design.
Responsive Design: Added media queries to ensure the layout is mobile-friendly.
Improved Aesthetics: Enhanced buttons, service list items, and overall layout for a modern look.
HTML Structure:
Service List: Organized each service within a <li> with better semantics and structure.
Conditional Display: Added a message when there are no services to display.
Security Enhancements:
HTML Escaping: Used htmlspecialchars to prevent XSS attacks.
Format Description: Used nl2br to maintain line breaks in descriptions.
Sample header.php and footer.php
Ensure that your header.php and footer.php contain the necessary HTML elements. Here's a simple example of what they might contain:
includes/header.php
php
<!-- Example Header Content -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<!-- Add any additional CSS or JS files here -->
Note: Adjust the content of header.php and footer.php based on your project's requirements. The above examples are simplistic and meant to provide a starting point.
Additional Recommendations
Separate CSS File:
For better maintainability, consider moving the CSS to a separate .css file and include it via a <link> tag in your header.php.
Navbar Integration:
If your header.php includes a navigation bar, ensure it complements the design of the manage_services.php page.
Form Validation:
Implement both client-side and server-side validation to enhance user experience and security.
Security Measures:
CSRF Protection: Implement CSRF tokens in your forms to prevent Cross-Site Request Forgery.
Input Sanitization: Ensure all user inputs are properly sanitized before processing.
By following the above structure and recommendations, your manage_services.php page will have a cohesive and modern design, integrated seamlessly with your header and footer includes.