forked from rizkadwisaputra/inventorybarang
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathubahadmin.php
82 lines (80 loc) · 2.59 KB
/
ubahadmin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
$admin = new \Ataslangit\DB\Admin();
?>
<div class="row">
<div class="col-md-12">
<div class="box">
<div class="box-header">
<h3 class="box-title" style="padding-top:0; margin-top:0; color:#f00;">Ubah Admin</h3>
</div>
<hr/>
<div class="box-body">
<?php
if (isset($_POST['save'])) {
$admin->ubah_admin($_POST['email'], $_POST['pass'], $_POST['nama'], $_FILES['gambar'], $_GET['id']);
echo "<script>bootbox.alert('Data Terubah', function(){
window.location = 'index.php?page=admin';
});</script>";
}
$adm = $admin->ambil_admin($_GET['id']);
?>
<form method="POST" id="forminput" enctype="multipart/form-data">
<div class="form-group">
<label>Email</label>
<input type="email" class="form-control" name="email" id="formemail" value="<?= $adm['email']; ?>" placeholder="Masukan Email">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" name="pass" id="formpass" value="<?= $adm['password']; ?>" placeholder="Masukan Password">
</div>
<div class="form-group">
<label>Nama</label>
<input type="text" class="form-control" name="nama" id="formnama" value="<?= $adm['nama']; ?>" placeholder="Masukan Nama">
</div>
<div class="form-group">
<label>Gambar</label>
<img src="gambar_admin/<?= $adm['gambar']; ?>" width="50" class="img-responsive">
<input type="file" class="form-control" name="gambar" id="formgambar">
</div>
<button id="formbtn" class="btn btn-primary" name="save"><i class="fa fa-save"></i> Simpan</button>
<a href="index.php?page=admin" class="btn btn-warning"><i class="fa fa-arrow-left"></i> Back to admin</a>
</form>
</div>
</div>
</div>
</div>
<script>
//fungsi hide div
$(function(){
setTimeout(function(){$("#divAlert").fadeOut(900)}, 500);
});
function validateText(id){
if ($('#'+id).val()== null || $('#'+id).val()== "") {
var div = $('#'+id).closest('div');
div.addClass("has-error has-feedback");
return false;
}
else{
var div = $('#'+id).closest('div');
div.removeClass("has-error has-feedback");
return true;
}
}
$(document).ready(function(){
$("#formbtn").click(function(){
if (!validateText('formemail')) {
$('#formemail').focus();
return false;
}
if (!validateText('formpass')) {
$('#formpass').focus();
return false;
}
if (!validateText('formnama')) {
$('#formnama').focus();
return false;
}
return true;
});
});
</script>