
<div class='row'>
    <div class='col-md-12'>
        <div class="card">
             <div class="card-header">	
               <h5 class="card-title"><i class="fas fa-edit"></i>Ubah Profil</h5>
            </div>
            <div class='card-body'>
	<form id="formprofil" action="" enctype="multipart/form-data">
            <div class="card-body">
                    <div class="row">
						<div class="col-md-6">
                                <div class="form-group">
								<?php
								$tgl=date('Y-m-d');
                            $query = mysqli_query($koneksi, "select * FROM users WHERE id_user='$_SESSION[id_user]' ");  
                            $pr = (mysqli_fetch_array($query));
                               
                            ?>
							  <center>
							<?php if($pr['foto']==''){ ?>
					  <img src="../dist/img/avatar.png" width="200">
							<?php }else{ ?>
					  <img src="../<?= $pr['foto'] ?>" style="border-radius:50%;width:200px">
					  <?php } ?>
					  </center>
					  
                    </div>
					</div>
					<div class="col-md-6">
					<div class="form-group">
                        <label class="bold">Username</label>
                      <input  type="text" class="form-control" value="<?= $pr['username'] ?>" readonly />
                    <input  type="hidden" name="idu" class="form-control" value="<?= $pr['id_user'] ?>"  />					  
                    </div>
					<div class="form-group">
                        <label class="bold">Nama</label>
                      <input  type="text" class="form-control" name="nama" value="<?= $pr['nama'] ?>" />  	                                 
                    </div>
					<div class="form-group">
                        <label class="bold">Ambil Photo</label>
                      <input name="MAX_FILE_SIZE" type="hidden" value="3000000" />  
	                                  <input name="gambar" class="form-control" type="file" accept="image/*" capture / required>
                    </div>
					</div>
					</div>
					<div class="right">					
                  <button name="gantiphoto" type="submit" class="btn btn-outline-primary" > Ubah Profil</button>				  
                </div>
                    </form>
            </div>
              </div>
            </div>
        </div>
 
 <script>
	$('#formprofil').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
      
        $.ajax({
            type: 'POST',
            url: 'sandik_admin/crud_admin.php?pg=profil',
            enctype: 'multipart/form-data',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
              iziToast.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil disimpan',
				titleColor: '#FFFF00',
				messageColor: '#fff',
				backgroundColor: 'rgba(0, 0, 0, 0.5)',
				 progressBarColor: '#FFFF00',
                  position: 'topRight'
                    });
                setTimeout(function() {
                    window.location.replace('?');
                }, 2000);

            }
        });
        return false;
    });
</script>
  