-
Notifications
You must be signed in to change notification settings - Fork 2
/
profileedit.php
94 lines (83 loc) · 3.32 KB
/
profileedit.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
<?php
// session_start();
require("header.php");
include "Conn.php"; // Using database connection file here
$id = $_GET['id']; // get id through query string
$qry = mysqli_query($conn, "select * from users where userID='$id'"); // select query
$pdts = mysqli_fetch_array($qry); // fetch data
if (isset($_POST['update'])) // when click on Update button
{
$name = $_POST['name'];
$password = $_POST['password'];
$edit = mysqli_query($conn, "update users set userName='$name', userPassword='$password' where userID='$id'");
if ($edit) {
// mysqli_close($conn); // Close connection
// header("location:profile.php"); // redirects to all records page
?>
<script>
location.replace("profile.php");
</script>
<?php
exit;
} else {
echo "Error occur";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container py-5">
<form method="POST" class="needs-validation" novalidate>
<div class="form-group">
<div class="row">
<div class="col">
<label for="name">First Name:</label>
<input type="text" class="form-control" id="name" value="<?php echo $pdts['userName'] ?>" name="name" autofocus>
<div class="valid-feedback">Valid.</div>
<div class="invalid-feedback">Please enter valid Input.</div>
</div>
</div>
</div>
<div class="form-group">
<label for="password">Address:</label>
<input type="text" class="form-control" value="<?php echo $pdts['userPassword'] ?>" id="password" name="password" required>
<div class="valid-feedback">Valid.</div>
<div class="invalid-feedback">Please enter valid Input.</div>
</div>
<button type="submit" name="update" class="btn btn-primary">Update</button>
</form>
</div>
<script>
// Disable form submissions if there are invalid fields
(function() {
'use strict';
window.addEventListener('load', function() {
// Get the forms we want to add validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}, false);
})();
</script>
</body>
<?php include "footer.php"; ?>
</html>