-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofil.php
169 lines (140 loc) · 6.84 KB
/
profil.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
session_start();
include 'db.php';
if($_SESSION['status_login'] != true){
echo '<script>window.location="login.php"</script>';
}
$query = mysqli_query($conn, "SELECT * FROM tb_admin WHERE id_admin = '".$_SESSION['id']."' ");
$d = mysqli_fetch_object($query);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0" />
<title>Profil</title>
<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection" />
</head>
<body>
<!--===== HEADER =====-->
<nav class="teal darken-2 lighten-1" role="navigation">
<div class="nav-wrapper container"><a id="logo-container" href="#" class="brand-logo">Dashboard</a>
<ul class="right hide-on-med-and-down">
<li><a href="dashboard.php">Dashboard</a></li>
<li><a href="profil.php">Profil</a></li>
<li><a href="data-kategori.php">Data Kategori</a></li>
<li><a href="data-produk.php">Data Produk</a></li>
<li><a href="keluar.php">Keluar</a></li>
</ul>
<ul id="nav-mobile" class="sidenav">
<li><a href="dashboard.php">Dashboard</a></li>
<li><a href="profil.php">Profil</a></li>
<li><a href="data-kategori.php">Data Kategori</a></li>
<li><a href="data-produk.php">Data Produk</a></li>
<li><a href="keluar.php">Keluar</a></li>
</ul>
<a href="#" data-target="nav-mobile" class="sidenav-trigger"><i class="material-icons">menu</i></a>
</div>
</nav>
<!--===== KONTEN =====-->
<div class="section">
<div class="container">
<h4>Profil</h4>
<div class="box">
<form action="" method="POST" >
<div class="input-field col s12">
<input id="nama" type="text" name="nama" placeholder="Nama Lengkap" class="input-control" value="<?php echo $d->nama_admin ?>" required>
<label for="nama">Nama Lengkap</label>
</div>
<div class="input-field col s12">
<input id="user" type="text" name="user" placeholder="Username" class="input-control" value="<?php echo $d->username ?>" required>
<label for="user">Username</label>
</div>
<div class="input-field col s12">
<input id="hp" type="text" name="hp" placeholder="No Handphone" class="input-control" value="<?php echo $d->telp_admin ?>" required>
<label for="hp">No. Handphone</label>
</div>
<div class="input-field col s12">
<input id="email" type="email" name="email" placeholder="Email" class="input-control" value="<?php echo $d->email_admin ?>" required>
<label for="email">Email</label>
</div>
<div class="input-field col s12">
<input id="alamat" type="text" name="alamat" placeholder="Alamat" class="input-control" value="<?php echo $d->alamat_admin ?>" required>
<label for="alamat">Alamat</label>
</div>
<button class="btn waves-effect waves-light" type="submit" name="submit">Ubah Profil
</button>
</form>
<?php
if(isset($_POST['submit'])){
$nama = ucwords($_POST['nama']);
$user = $_POST['user'];
$hp = $_POST['hp'];
$email = $_POST['email'];
$alamat = ucwords($_POST['alamat']);
$update = mysqli_query($conn, "UPDATE tb_admin SET
nama_admin = '". $nama."',
username = '". $user."',
telp_admin = '". $hp."',
email_admin = '". $email."',
alamat_admin = '". $alamat."'
WHERE id_admin ='".$d->id_admin."' ");
if($update){
echo '<script>alert("Ubah data Berhasil")</script>';
echo '<script>window.location="profil.php"</script>';
}else{
'Gagal Update Profil '.mysqli_error($conn);
}
}
?>
</div>
</div>
</div>
<div class="container">
<div class="section">
<h4>Ubah Password</h4>
<div class="box">
<form action="" method="POST">
<input type="password" name="pass1" placeholder="Password Baru" class="input-control" required>
<input type="password" name="pass2" placeholder=" Konfirmasi Password Baru" class="input-control" required>
<button class="btn waves-effect waves-light" type="submit" name="ubah_password">Ubah Password
</button>
</form>
<?php
if(isset($_POST['ubah_password'])){
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
if($pass2 !=$pass1){
echo '<script>alert("Konfirmasi Password Baru tidak Sesuai")</script>';
}else{
$u_pass = mysqli_query($conn, "UPDATE tb_admin SET
password = '".MD5($pass1)."'
WHERE id_admin ='".$d->id_admin."' ");
if($u_pass){
echo '<script>alert("Ubah data Berhasil")</script>';
echo '<script>window.location="profil.php"</script>';
}else{
'Gagal Update Profil '.mysqli_error($conn);
}
}
}
?>
</div>
</div>
</div>
<!--===== FOOTER =====-->
<footer>
<div class="container">
<small>Copyright © 2022 <a class="teal-text text-darken-2 " href="https://www.himang.my.id/">Himang.my.id</a></small>
</div>
</footer>
<!-- Scripts-->
<script src="https://code.jquery.com/jquery-2.1.1.min.js "></script>
<script src="js/materialize.js "></script>
<script src="js/init.js "></script>
</body>
</html>