<?php session_start();
error_reporting(0);
include("include/dbConfig.php");


// FETCHING SITENAME
// $query = $db->query("SELECT * FROM misc WHERE name='site_name'");

// while($row = $query->fetch_assoc()){
//     $site_name = $row['value'];
// }


if (strlen($_SESSION['alogin'])==0) {
    
    echo '<script>window.location="login.php"</script>';
    
} else {

    $update_alert = false;

        if(isset($_POST['save'])){

            $update_query = "UPDATE users SET user_name = '".$_POST['name']."', user_email = '".$_POST['email']."', user_pass = '".$_POST['pass']."' WHERE user_id =  ".$_SESSION['userid'];

            if(mysqli_query($db, $update_query)){
                $_SESSION['alogin'] = $_POST['name'];
                $update_alert =  true;
            }
        }


    ?> <!doctype html>
<html lang="en">

    
<!-- Mirrored from themesbrand.com/symox/layouts/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 14 Jan 2022 05:37:58 GMT -->
<head>
        
        <meta charset="utf-8" />
        <title>My Account | Admin </title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta content="Premium Multipurpose Admin & Dashboard Template" name="description" />
        <meta content="Themesbrand" name="author" />
        <!-- App favicon -->
        <link rel="shortcut icon" href="assets/images/favicon.ico">
  <!-- gridjs css -->
        <link rel="stylesheet" href="assets/libs/gridjs/theme/mermaid.min.css">

        <!-- Bootstrap Css -->
        <link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
        <!-- Icons Css -->
        <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
        <!-- App Css-->
        <link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
        <link href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css"  rel="stylesheet" type="text/css" />


    </head>

    <body data-layout="horizontal" data-topbar="dark">

    
            <!-- Left Sidebar End -->
            <header id="page-topbar" class="ishorizontal-topbar">
                <div class="navbar-header">
                    <div class="d-flex">
                        <!-- LOGO -->
                        <div class="navbar-brand-box">
                            <a href="dashboard.php" class="logo logo-dark">
                                <span class="logo-sm">
                                    <img src="assets/images/logo-sm.svg" alt="" height="22">
                                </span>
                                <span class="logo-lg">
                                    <img src="assets/images/logo-sm.svg" alt="" height="22"> <span class="logo-txt">Durood Counter</span>
                                </span>
                            </a>

                            <a href="dashboard.php" class="logo logo-light">
                                <span class="logo-sm">
                                    <img src="assets/images/logo-sm.svg" alt="" height="22">
                                </span>
                                <span class="logo-lg">
                                    <img src="assets/images/logo-sm.svg" alt="" height="22"> <span class="logo-txt">Durood Counter</span>
                                </span>
                            </a>
                        </div>

                        <button type="button" class="btn btn-sm px-3 font-size-16 d-lg-none header-item" data-bs-toggle="collapse" data-bs-target="#topnav-menu-content">
                            <i class="fa fa-fw fa-bars"></i>
                        </button>

                        <div class="topnav">
                            <nav class="navbar navbar-light navbar-expand-lg topnav-menu">
        
                                <div class="collapse navbar-collapse" id="topnav-menu-content">
                                    <ul class="navbar-nav">
                                        <li class="nav-item">
                                            <a class="nav-link dropdown-toggle arrow-none" href="dashboard.php" id="topnav-dashboard" role="button"
                                                data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                <i class='bx bx-tachometer'></i>
                                                <span data-key="t-dashboards">Dashboard</span>
                                            </a>
                                        </li>
        

        
                                    </ul>
                                </div>
                            </nav>
                        </div>
                    </div>

                    <div class="d-flex">
                   
                        <div class="dropdown d-none d-sm-inline-block">
                            <button type="button" class="btn header-item light-dark" id="mode-setting-btn">
                                <i data-feather="moon" class="icon-sm layout-mode-dark "></i>
                                <i data-feather="sun" class="icon-sm layout-mode-light"></i>
                            </button>
                        </div>

                        <div class="dropdown d-inline-block">
                            <button type="button" class="btn header-item user text-start d-flex align-items-center" id="page-header-user-dropdown"
                                data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <img class="rounded-circle header-profile-user" src="assets/images/users/avatar-1.jpg"
                                alt="Header Avatar">
                            </button>
                            <div class="dropdown-menu dropdown-menu-end pt-0">
                                <a class="dropdown-item" href="account-settings.php"><i class='bx bx-user-circle text-muted font-size-18 align-middle me-1'></i> <span class="align-middle">My Account</span></a>
                                
                                <div class="dropdown-divider"></div>
                                <a class="dropdown-item" href="sign-out.php"><i class='bx bx-log-out text-muted font-size-18 align-middle me-1'></i> <span class="align-middle">Logout</span></a>
                            </div>
                        </div>
                    </div>
                </div>
            </header>
    


            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="main-content">

                <div class="page-content">
                    <div class="container-fluid">

                        <!-- start page title -->
                        <div class="row">
                            <div class="col-12">
                                <div class="page-title-box d-flex align-items-center justify-content-between">
                                    <h4 class="mb-0">Welcome <?php echo $_SESSION['alogin']; ?>!</h4>

                                    <div class="page-title-right">
                                        <ol class="breadcrumb m-0">
                                            <li class="breadcrumb-item"><a href="javascript: void(0);">Durood</a></li>
                                            <li class="breadcrumb-item active">Welcome <?php echo $_SESSION['alogin']; ?>!</li>
                                        </ol>
                                    </div>

                                </div>
                            </div>
                        </div>
                        <?php  if($update_alert == true) {?>
                        <div class="alert alert-success alert-dismissible fade show" role="alert">
                            <i class="mdi mdi-check-all me-2"></i>
                           Account Settings Updated
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                        </div>
                    <?php } ?>


                        <form method="post" action=""> 
                        <!-- end page title -->
                            <?php $query = $db->query("SELECT * FROM users WHERE user_id = ".$_SESSION['userid']); 


                            while($row = $query->fetch_assoc()){
                            ?>

                        <div class="row">   
                                  <div class="col-md-4">
                                    <label>Your Name</label>
                                    <input type="text" class="form-control" name="name" value="<?php echo $row['user_name'] ?>" required>

                                  </div>
                                  <div class="col-md-8"></div>
                                  <div class="col-md-4">
                                    <label>Email</label>
                                    <input type="email" class="form-control" name="email" value="<?php echo $row['user_email'] ?>" required>

                                  </div>
                                  <div class="col-md-8"></div>
                                  <div class="col-md-4">
                                    <label>Password</label>
                                    <input type="text" class="form-control" name="pass" value="<?php echo $row['user_pass'] ?>">

                                  </div>
                                  <div class="col-md-8"></div>
                                  <hr>
                                  <div class="col-md-4">
                                      <input type="submit" name="save" value="Save changes" class="btn btn-info">
                                  </div>
                                  
                        </div>
                    <?php } ?>
                      </form>
                        
                    </div> <!-- container-fluid -->
                </div>
                <!-- End Page-content -->

                
                <footer class="footer">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-6">
                                <script>document.write(new Date().getFullYear())</script> &copy; Darood Counter.
                            </div>
                            <div class="col-sm-6">
                                <div class="text-sm-end d-none d-sm-block">
                                    Made with <i class="mdi mdi-heart text-danger"></i> by <a href="https://eclosol.com/" target="_blank" class="text-reset">Eclosol</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </footer>
            </div>
            <!-- end main content-->

        </div>
        <!-- END layout-wrapper -->

       
 
        <!-- JAVASCRIPT -->
        <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
        <script src="assets/libs/metismenujs/metismenujs.min.js"></script>
        <script src="assets/libs/simplebar/simplebar.min.js"></script>
        <script src="assets/libs/feather-icons/feather.min.js"></script> 
        

        <!-- gridjs js -->
        <script src="assets/libs/gridjs/gridjs.umd.js"></script>

        <script src="assets/js/pages/gridjs.init.js"></script>

        <script src="assets/js/app.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
            <script type="text/javascript">
                
                $(document).ready(function(){
                        $('#example').DataTable( {
        "order": [[ 0, "desc" ]]
    } );
                });
            </script>

    </body>


</html>
<?php } ?>