-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-user.php
More file actions
48 lines (36 loc) · 1.11 KB
/
update-user.php
File metadata and controls
48 lines (36 loc) · 1.11 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<title>update data user</title>
</head>
<body>
</body>
<?php
require_once 'db.php';
$conn = konek_db();
if(!isset($_GET['username']))
die("Tidak ditemukan username");
$username =$_GET['username'];
$query = $conn->prepare("select * from user where username=?");
$query->bind_param('s',$username);
$result = $query->execute();
if(!$result)
die("Gagal query");
$rows = $query->get_result();
if($rows->num_rows == 0)
die("user tidak detemukan");
if(!isset($_POST['name']) || !isset($_POST['password']) || !isset($_POST['category']))
die("Data user tidak lengkap");
$name = $_POST['name'];
$password = $_POST['password'];
$category = $_POST['category'];
$query = $conn->prepare("update user set name=?,password=?,category=? where username=?");
$query->bind_param('ssss',$name,$password,$category,$username);
$result=$query->execute();
if($result)
echo "<script type='text/javascript'>alert('Update Berhasil');window.location.href = 'admin.php';</script>";
else
echo "<script type='text/javascript'>alert('Update Gagal');window.location.href = 'admin.php';</script>";
?>
</body>
</html>