<?php include('common/header.php'); ?>
  <!-- Main Sidebar Container -->
<?php include('common/sidenav.php'); ?>


  <!-- Content Wrapper. Contains page content -->
<!--For save data-->

<?php
 include_once ('includes/config.php');
   
// Check connection
    if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
    } 

if(isset($_POST['submit']))
{
 
$sess= $_SESSION['sess_user'];


   
//insert.php
$name =$_POST['name'];
$email =$_POST['email'];
$password =$_POST['password'];







 // Check connection
    if ($con->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    } 
  else

 

   
   $sql="UPDATE `user_info` Set `name`='".$name."', `password`='".$password."' WHERE name='$sess'";
  

 
 
  


if ($con->multi_query($sql) === TRUE) 
{
   //  echo "Successfully Changed";

  //echo "<div class='container'><div class='custom-alert'>Session Expired You Need To Login Again.</div></div>";
    //    echo "<script>setTimeout(function() { window.location.href='logout.php'; }, 1000);</script>";

?>
  <script>
        alert('Session Expired You Need To Login Again.');
        window.location.href='logout.php';
    </script>
<?php
}
else {
    echo "Error: " . $sql . "<br>" . $con->error;
  }

$con->close();
}
 ?>

  <div class="content-wrapper">

 <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Profile</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
            <!--  <li class="breadcrumb-item"><a href="shopslist.php">Dataview</a></li>-->
             <li class="breadcrumb-item active"><a href="dashboard.php">Dashboard</a></li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

 <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <!-- SELECT2 EXAMPLE -->
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">Edit Info</h3>
 <?php
                    include('includes/config.php');
                    
        
       $sess= $_SESSION['sess_user'];
    $result = mysqli_query($con, "SELECT * FROM `user_info`  WHERE name='$sess'");
   while($row = mysqli_fetch_assoc($result)) {
                
                    
            ?>
            <div class="card-tools">
              <button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
              <button type="button" class="btn btn-tool" data-card-widget="remove"><i class="fas fa-times"></i></button>
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body">
          	<form method="post">
          	  
            <div class="row">
              <div class="col-md-4">
                <div class="form-group">
                  <label>Name</label>
                 <input type="text" required="required"  class="form-control" name="name" placeholder="Full Name" value="<?php echo $row['name'];  ?>">
                </div>
            </div>
                <!-- /.form-group -->
                 <div class="col-md-4">
                <div class="form-group">
                  <label>Email</label>
                 <input type="email" required="required" readonly class="form-control" name="email" placeholder="Email" value="<?php echo $row['email'];  ?>">
                </div>
            </div>
                 <div class="col-md-4">
                <div class="form-group">
                	 <label>Password</label>
                <input type="text" required="required" class="form-control" name="password" placeholder="Choose a Password" value="<?php echo $row['password'];  ?>">
                
                </div>
                <!-- /.form-group -->
              </div>
          </div>

             
              <!-- /.col -->
             
            <!-- /.row -->
<?php
}

?>
        
          </div>
          <!-- /.card-body -->
          <div class="card-footer">
           <button type="submit" name="submit" class="btn btn-danger">Submit</button>
          </div>
</form>
        <!-- /.card -->


  
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->



  </div>
  <!-- /.content-wrapper -->






<?php include('common/footer.php'); ?>