    <?php
        require('top_inc.php');
        $name='';
        $image='';
        $descri='';


        $msg='';
        $msg1='';
        $image_required='required';

        if (isset($_GET['id']) && $_GET['id']!='') {
            $image_required='';
            $id=get_safe_value($con,$_GET['id']);
            $res=mysqli_query($con, "select * from why_choose_us where id='$id'");
            $check=mysqli_num_rows($res);
            if($check>0){
                $row=mysqli_fetch_assoc($res);
                $name=$row['name'];
                $descri=$row['descri'];
                $image=$row['image'];
            }
            else{
            }
        }

        if(isset($_POST['submit'])){
            $name=get_safe_value($con,$_POST['name']);
            $descri=get_safe_value($con,$_POST['descri']);
            $image=get_safe_value($con,$_POST['image']);

            $res=mysqli_query($con, "select * from why_choose_us where name='$name'");
            
            if($msg==''){
                if (isset($_GET['id']) && $_GET['id']!='') {
                    $update_sql="update why_choose_us set name='$name',descri='$descri',image='$image' where id='$id'";
                }
                else{
                    mysqli_query($con,"insert into why_choose_us(name,descri,image,status) values('$name','$descri','$image',1)");
                }
                $msg1="Categories successfull submit";
                
            }

        }
        
    ?>
        <!-- Page Area Start Here -->
        <div class="dashboard-page-one">
            <!-- Sidebar Area Start Here -->
            <?php
                require('side_menu.php');
            ?>
            <!-- Sidebar Area End Here -->
            <div class="dashboard-content-one">
                <!-- Breadcubs Area Start Here -->
                <div class="breadcrumbs-area">
                    <h3>Add Why Choose Us</h3>
                    <ul>
                        <li>
                            <a href="index.php">Home</a>
                        </li>
                        <li>Add Team</li>
                    </ul>
                </div>
                <!-- Breadcubs Area End Here -->
                <!-- Student Table Area Start Here -->
                <div class="card height-auto">
                    <div class="card-body">
                        <div class="heading-layout1">
                            <div class="item-title">
                                <h3>Add Team</h3>
                            </div>
                        </div>
                        <form method="post" enctype="multipart/form-data" class="mg-b-20">
                            <div class="row gutters-8">
                                <div class="col-3-xxxl col-xl-6 col-lg-6 col-12 form-group">
                                    <input type="text" placeholder="Enter Product name ..." class="form-control" name="name" value="<?php echo $name; ?>">
                                </div>
                                <div class="col-3-xxxl col-xl-6 col-lg-6 col-12 form-group">
                                    <input type="text" placeholder="Enter Designation ..." class="form-control" name="descri" value="<?php echo $descri; ?>">
                                </div>
                                <div class="col-3-xxxl col-xl-12 col-lg-12 col-12 form-group">
                                    <select name="image" class="form-control">
                                        <option><i class="flaticon-cogwheel"></i></option>
                                        <option><i class="flaticon-cloud-storage"></i></option>
                                        <option><i class="flaticon-globe-grid"></i></option>
                                        <option><i class="flaticon-backup"></i></option>
                                    </select>
                                </div>

                                <div class="col-1-xxxl col-xl-12 col-lg-12 col-12 form-group">
                                    <button type="submit" name="submit" class="fw-btn-fill btn-gradient-yellow">SUBMIT</button>
                                </div>
                            </div>
                        </form>
                        <div class="field_error">
                            <?php echo $msg ?>
                        </div>
                        <div class="field_error">
                            <?php echo $msg1 ?>
                        </div>
                    </div>
                </div>
                <!-- Student Table Area End Here -->
                <?php
                    require('footer_inc.php');
                ?>