<?php
include "ominterior_db.php";


// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get the data from the form
    $section_title = $_POST['section_title'];
    $heading = $_POST['heading'];
    $content = $_POST['content'];
    $icon = $_POST['icon']; // New icon field

    // Validate inputs (basic validation for empty fields)
    if (empty($section_title) || empty($heading) || empty($content) || empty($icon)) {
        echo "Please fill in all the fields.";
    } else {
        // Sanitize input data to prevent SQL injection
        $section_title = $conn->real_escape_string($section_title);
        $heading = $conn->real_escape_string($heading);
        $content = $conn->real_escape_string($content);
        $icon = $conn->real_escape_string($icon);

        // Prepare the SQL query to insert the data
        $sql = "INSERT INTO about_section (section_title, heading, content, icon)
                VALUES ('$section_title', '$heading', '$content', '$icon')";

        // Execute the query
        if ($conn->query($sql) === TRUE) {
            echo "Data saved successfully!";
        } else {
            echo "Error: " . $conn->error;
        }
    }
}

// Close the connection
$conn->close();

?>

<!doctype html>
<html lang="en" dir="ltr">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<link rel="icon" href="assets/images/black-logo.png" type="image/x-icon"/>

<title>OM INTERIOR - Dashborad</title>

<!-- Bootstrap Core and vandor -->
<link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css" />

<!-- Plugins css -->
<link rel="stylesheet" href="assets/plugins/charts-c3/c3.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">


<!-- Core css -->
<link rel="stylesheet" href="assets/css/main2.css"/>
<link rel="stylesheet" href="assets/css/theme1.css"/>
</head>

<body class="font-montserrat">
<!-- Page Loader -->
<div class="page-loader-wrapper">
    <div class="loader">
    </div>
</div>

<div id="main_content">
    
    <?php include 'haderTop_logo.php'?>
        
    <?php include 'rightside_menu.php'?>

    <?php include 'leftside_menu.php' ?>

    <div class="page">
        <div id="page_top" class="section-body top_dark">
            <div class="container-fluid">
                <div class="page-header">
                    <div class="left">
                        <a href="javascript:void(0)" class="icon menu_toggle mr-3"><i class="fa  fa-align-left"></i></a>
                        <h1 class="page-title">About Section</h1>                        
                    </div>
                    <div class="right">
                        <?php include 'dropdown_flex_menu.php' ?>
                    </div>
                </div>
            </div>
        </div>

        <div class="row clearfix">
            <div class="col-12 col-sm-12">
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">Add About Text</h3>
                    </div>
                </div>
            </div>

            <div class="container my-5">
                <div class="row justify-content-center">
                    <div class="col-md-12">
                        <div class="card shadow">
                            <div class="card-header bg-dark text-white">
                                <h4 class="mb-0">Add About Section</h4>
                            </div>
                            <div class="card-body">
                                <form method="POST">
                                    <div class="mb-3">
                                        <label for="section_title" class="form-label">Section Title</label>
                                        <input type="text" name="section_title" id="section_title" class="form-control" required>
                                    </div>

                                    <div class="mb-3">
                                        <label for="heading" class="form-label">Heading</label>
                                        <input type="text" name="heading" id="heading" class="form-control" required>
                                    </div>

                                    <div class="mb-3">
                                        <label for="heading" class="form-label">Icon</label>
                                        <input type="text" name="icon" id="icon" class="form-control" required>
                                    </div>

                                    <div class="mb-3">
                                        <label for="content" class="form-label">Content</label>
                                        <textarea name="content" id="content" class="form-control" rows="6" required></textarea>
                                    </div>

                                    <div class="d-grid">
                                        <button type="submit" class="btn btn-success">Save</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
        <div class="section-body">
            <footer class="footer">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-12 col-sm-12 text-md-right">
                            <ul class="list-inline mb-0">
                                <li class="list-inline-item"><a href="doc/index.html">OM INTERIOR</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </footer>
        </div>
    </div>    
</div>



<script src="assets/bundles/lib.vendor.bundle.js"></script>

<script src="assets/bundles/apexcharts.bundle.js"></script>
<script src="assets/bundles/counterup.bundle.js"></script>
<script src="assets/bundles/knobjs.bundle.js"></script>
<script src="assets/bundles/c3.bundle.js"></script>

<script src="assets/js/core.js"></script>
<script src="assets/js/page/project-index.js"></script>
</body>
</html>