<?php include '../pages/header.php'?>
<?php include '../pages/navbar.php'?>
<?php include '../../conn.php'?>
<!--//////////////////////////////user fetch array///////////////-->
 <?php
     $userid=$_GET['id'];      
    $usersql="select * from users where id='$userid'";
    $userresult = mysqli_query($con,$usersql);
    $usersarry=array(); 
    while($userrow = mysqli_fetch_array($userresult)){
        $usersarry[]=$userrow;
    }
             
 ?>
<!--//////////////////////////////user fetch array///////////////-->
<!-- ///////////////////sign up funcation////////////////// -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function (e) {
 $("#form").on('submit',(function(e) {
  e.preventDefault();
  $.ajax({
   url: "api/editusers.php",
   type: "POST",
   data:  new FormData(this),
   contentType: false,
         cache: false,
   processData:false,
   beforeSend : function()
   {
    //$("#preview").fadeOut();
    $("#err").fadeOut();
   },
   success: function(data)
      {
    if(data == 101)
    {
     // invalid file format.
     
     $("#successmessage").html("Sucessfully Edit").fadeIn();
     $("#form")[0].reset(); 
     $("#message").html("").fadeIn();
      window.location.href = "#";
    }
   
   
    else{
    	alert(data);
    }
      },
     error: function(e) 
      {
   $("#successmessage").html("Some thing went  worng").fadeIn().style.color.red;
      }          
    });
 }));
});
</script>
<!-- //////////////////signup//////////////////////////// -->
<div class="content-wrapper">

<div class="container-fluid">

<div>

<div class="row">
<div class="col-sm-12 p-0">
<div class="main-header">
<h4>Edit Form</h4>

</div>
</div>
</div>
<span class="successmessage" id="successmessage"></span>

<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<!--<h5 class="card-header-text">Basic Form Validation</h5></div>-->
<div class="card-block">
    <?php foreach($usersarry as $data){?>
<form  class="form-horizontal" action="#" method="post" id="form"  enctype="multipart/form-data" novalidate>
    <input type="hidden" class="md-form-control" name="id" id="id" value="<?php echo $data['id']?>">
<div class="md-group-add-on p-relative">
<span class="md-add-on">
<i class="icofont icofont-ui-user"></i>
</span>
<div class="md-input-wrapper">
<input type="text" class="md-form-control" name="name" id="name" value="<?php echo $data['name']?>">
<label for="username">Full Name</label>
<span class="messages"></span>
</div>
</div>

<div class="md-group-add-on p-relative">
<span class="md-add-on">
<i class="icofont icofont-email"></i>
</span>
<div class="md-input-wrapper">
<input type="email" readonly class="md-form-control" name="email" id="email" value="<?php echo $data['email']?>">


</div>
</div>

<div class="md-group-add-on p-relative">
<span class="md-add-on">
<i class="icofont icofont-phone"></i>
</span>
<div class="md-input-wrapper">
<input type="text" class="md-form-control" name="phone" id="phone" value="<?php echo $data['phone']?>">
<label for="phone">Enter Mobile No</label>
<span class="messages"></span>
</div>
</div>
<img src="<?php echo $data['image']?>" height=50; width=50;>
<div class="md-group-add-on p-relative">
<span class="md-add-on">
<i class="icofont icofont-file"></i>
</span>
<div class="md-input-wrapper">
<input type="file" class="md-form-control" name="image" id="image">
<label for="file">Select image</label>

</div>
</div>

<div class="md-input-wrapper">
<button type="submit" id="btn" class="btn btn-primary waves-effect waves-light">Submit
</button>
</div>
</form>
<?php }?>
</div>
</div>

<?php include '../pages/footer.php'?>
