<?php

include 'ominterior_db.php'; // Ensure connection is established

// Insert logic
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $icon = $conn->real_escape_string($_POST['icon']);
    $percentage = $conn->real_escape_string($_POST['percentage']);
    $title = $conn->real_escape_string($_POST['title']);

    $sql = "INSERT INTO skills (icon, percentage, title) VALUES ('$icon', '$percentage', '$title')";

    if ($conn->query($sql) === TRUE) {
        $message = "Skill added successfully!";
        header('location:services.php');
    } else {
        $message = "Error: " . $conn->error;
    }

    $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 - Gallery</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 href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

<!-- 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">Services</h1>                        
                    </div>
                    <div class="right">
                        <?php include 'dropdown_flex_menu.php' ?>
                    </div>
                </div>
            </div>
        </div>

                <div class="container py-5">
                    <h2 class="mb-4">Add New Skill</h2>
                    
                    <?php if (!empty($message)): ?>
                        <div class="alert alert-info"><?= $message ?></div>
                    <?php endif; ?>

                    <form method="post">
                        <div class="mb-3">
                            <label class="form-label">Lordicon URL</label>
                            <input type="text" name="icon" class="form-control" placeholder="e.g. https://cdn.lordicon.com/bhfjfgqz.json" required>
                        </div>

                        <div class="mb-3">
                            <label class="form-label">Percentage</label>
                            <input type="text" name="percentage" class="form-control" placeholder="e.g. 95%" required>
                        </div>

                        <div class="mb-3">
                            <label class="form-label">Title</label>
                            <input type="text" name="title" class="form-control" placeholder="e.g. Interior Sketch" required>
                        </div>

                        <button type="submit" class="btn btn-primary">Add Skill</button>
                    </form>
                </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>
    function toggleForm() {
        // Replace 'newpage.html' with your actual target page
        window.location.href = 'services.php';
    }
</script>



<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>
