-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproses_ubah_user.php
More file actions
34 lines (31 loc) · 1.48 KB
/
Copy pathproses_ubah_user.php
File metadata and controls
34 lines (31 loc) · 1.48 KB
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
<?php
if($_POST){
$id_user=$_POST['id_user'];
$nama_user=$_POST['nama_user'];
$username=$_POST['username'];
$password=$_POST['password'];
$role=$_POST['role'];
if(empty($nama_user)){
echo "<script>alert('nama user tidak boleh kosong');location.href='user.php';</script>";
} elseif(empty($username)){
echo "<script>alert('username tidak boleh kosong');location.href='user.php';</script>";
} else {
include "koneksi.php";
if(empty($password)){
$update=mysqli_query($conn,"update user set nama_user='".$nama_user."',username='".$username."',role='".$role."' where id_user = '".$id_user."'") or die(mysqli_error($conn));
if($update){
echo "<script>alert('Sukses update user');location.href='user.php';</script>";
} else {
echo "<script>alert('Gagal update user');location.href='ubah_user.php?id_user=".$id_user."';</script>";
}
} else {
$update=mysqli_query($conn,"update user set nama_user='".$nama_user."', username='".$username."', password='".md5($password)."',role='".$role."' where id_user = '".$id_user."'") or die(mysqli_error($conn));
if($update){
echo "<script>alert('Sukses update user');location.href='user.php';</script>";
} else {
echo "<script>alert('Gagal update user');location.href='ubah_user.php?id_user=".$id_user."';</script>";
}
}
}
}
?>