-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_profile.php
93 lines (70 loc) · 2.86 KB
/
admin_profile.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
<?php
@include 'config.php';
session_start();
if (!isset($_SESSION['admin_name'])) {
header('location:login.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include "css/css.php"; ?>
<title>Profil admin | Kosan TPI</title>
</head>
<body>
<section id="contact" class="">
<div class="container">
<div class="row mb-5">
<div class="col-md-8 mx-auto text-center">
<h1>Edit Profil</h1>
</div>
</div>
<?php
if (isset($_POST["update"])) {
$userNewName = $_POST['updateUserName'];
$userNewEmail = $_POST['userEmail'];
$loggedInUser = $_SESSION['admin_name'];
$sql = "UPDATE user SET name = '$userNewName', email ='$userNewEmail' WHERE name = '$loggedInUser'";
$results = mysqli_query($conn, $sql);
// print_r($results);
$_SESSION['admin_name'] = $userNewName;
header('location:admin_page.php');
}
?>
<?php
if (isset($_POST["batal"])) {
header("location:admin_page.php");
}
?>
<form method="post">
<?php
$currentUser = $_SESSION['admin_name'];
$sql = "SELECT * FROM user WHERE name ='$currentUser'";
$gotResuslts = mysqli_query($conn, $sql);
if ($gotResuslts) {
if (mysqli_num_rows($gotResuslts) > 0) {
while ($row = mysqli_fetch_array($gotResuslts)) {
// print_r($row['name']);
?>
<div class="row g-3 justify-content-center">
<div class="col-md-7">
<input type="text" name="updateUserName" class="form-control" placeholder="Username" required value="<?php echo $row['name']; ?>">
</div>
<div class="col-md-7">
<input type="text" name="userEmail" class="form-control" placeholder="Email Address" required value="<?php echo $row['email']; ?>">
</div>
<div class="col-md-7">
<input class="btn btn_blue" href="admin_page.php" type="submit" name="update" class="btn btn-info" value="Update"></input>
<input class="btn btn-danger" href="admin_page.php" value="Batal" type="submit" name="batal"></input>
</div>
</div>
<?php
}
}
}
?>
</form>
</div>
</section>
</body>
</html>