-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_edit.php
More file actions
69 lines (55 loc) · 2.61 KB
/
user_edit.php
File metadata and controls
69 lines (55 loc) · 2.61 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<title>Update</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<header>
<h1>Update</h1>
</header>
<?php
$id = $_GET['user_id'];
$mysqli = new mysqli('localhost','root','','programming');
$query = $mysqli->query("SELECT * FROM users WHERE id='$id' LIMIT 0,1");
$user=$query->fetch_assoc();
if(isset($_POST['update'])){
$id=$_POST['id'];
$name=$_POST['name'];
$email=$_POST['email'];
$username=$_POST['username'];
$password=md5($_POST['password']);
$update=$mysqli->query("UPDATE users SET name='$name', email='$email', username='$username', password='$password' WHERE id='$id'");
if($update){
?>
<strong>Success!</strong> Data has been updated.
<?php
header("Location: user_management_admin.php");
}else{
?>
<strong>Failed!</strong>Error updating data.
<?php
}
}
?>
<div class="form">
<form method="POST" name="vform">
<p class="contact"><label for="id">ID</label></p>
<input type="text" id="id" name="id" value="<?php echo($user['id']) ?>" readonly/>
<p class="contact"><label for="name">Name</label></p>
<input type="text" id="name" name="name" value="<?php echo($user['name']) ?>"/>
<p class="contact"><label for="email">Email</label></p>
<input type="email" id="email" name="email" value="<?php echo($user['email']) ?>"/>
<p class="contact"><label for="username">Username</label></p>
<input type="text" id="username" name="username" value="<?php echo($user['username']) ?>" />
<p class="contact"><label for="password">Password</label></p>
<input type="password" id="password" name="password" value="<?php echo($user['password']) ?>"/>
<p class="contact"><label for="phone">Mobile phone</label></p>
<input type="text" id="phone" name="phone" value="<?php echo($user['phone']) ?>"/>
<input type="submit" class="button" name="update" id="update" tabindex="5" value="Update" >
<p><a href="user_management.php">User Management</a></p>
</form>
</div>
</div>
</body>
</html>