-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.php
More file actions
74 lines (64 loc) · 2.11 KB
/
edit.php
File metadata and controls
74 lines (64 loc) · 2.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
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
<?php
include_once 'config.php';
include_once 'function.php';
$employeeObj = new employeeData($conn);
$errors = array();
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
if (empty($name)) {
$errors[] = "Name is required";
}
if (empty($phone)) {
$errors[] = "Phone is required";
}
if (empty($email)) {
$errors[] = "Email is required";
}
if (empty($errors)) {
// Insert data
$row_select = $employeeObj->updateData($name, $phone, $email);
}
} else {
$user_id = $_GET['id'];
$row_select = $employeeObj->getUser($user_id);
}
?>
<html>
<body>
<?php include_once 'header.php'; ?>
<div class="container">
<h1 style="color: black; text-align:center; font-weight:800">Edit page</h1>
<form action="" method="POST">
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo $row_select['name']; ?>">
<br>
</div>
<div class="mb-3">
<label class="form-label">Phone</label>
<input type="text" class="form-control" id="phone" name="phone" value="<?php echo $row_select['phone']; ?>">
<br>
</div>
<div class="mb-3">
<label class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" value=" <?php echo $row_select['email']; ?>">
<br>
</div>
<button type="submit" class="btn btn-primary" name="submit" value="submit">Submit</button>
<a href="displaydata.php" class="btn btn-secondary">View Data</a>
</form>
</div>
<div class="container">
<?php
if (!empty($errors)) {
foreach ($errors as $error) {
echo "<p style='color:red; text-align:center; font-weight:800'>$error</p>";
}
}
?>
</div>
<?php include 'footer.php'; ?>
</body>
</html>