-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmupdate.php
More file actions
142 lines (126 loc) · 4.72 KB
/
mupdate.php
File metadata and controls
142 lines (126 loc) · 4.72 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
//Assuming this file contains the database connection logic
require_once 'includes/dbh.inc.php';
//Check if the HTTP request method is POST
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Check if 'updateinvoiceId' is set and not empty
if (isset($_POST['updateinvoiceId']) && !empty($_POST['updateinvoiceId'])) {
//Sanitize and retrieve data from the POST request
$invoiceId = mysqli_real_escape_string($conn, $_POST['updateinvoiceId']);
$projectId = mysqli_real_escape_string($conn, $_POST['projectId']);
$description = mysqli_real_escape_string($conn, $_POST['description']);
$payment = mysqli_real_escape_string($conn, $_POST['payment']);
$paymentStatus = mysqli_real_escape_string($conn, $_POST['paymentStatus']);
//Create an SQL query to update a Financial Record
$sql = "UPDATE fmdcrud SET projectId='$projectId', description='$description', payment='$payment', paymentStatus='$paymentStatus' WHERE invoiceId='$invoiceId'";
//Execute the SQL query
$result = mysqli_query($conn, $sql);
//Check if the query was successfull or display and error message
if ($result) {
echo '<script>alert("Financial Record updated successfully")</script>';
//Redirect to the 'display.php' page
header('location:display.php');
} else {
die(mysqli_error($conn));
}
}
}
// Fetch the initial data for the form
$invoiceId = $_GET['updateinvoiceId'];
$sql = "SELECT * FROM fmdcrud WHERE invoiceId=$invoiceId";
$result = mysqli_query($conn, $sql);
$_GET = mysqli_fetch_assoc($result);
$projectId = $_GET['projectId'];
$description = $_GET['description'];
$payment = $_GET['payment'];
$paymentStatus = $_GET['paymentStatus'];
?>
<!doctype html>
<html lang="ar" dir="ltl">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #f4f4f4;
background-image: url("https://startupbiz.co.zw/wp-content/uploads/2023/05/7-Construction-Business-Ideas-For-Zimbabwe.jpg");
background-size:Cover;
}
h2{
margin-left: 30px;
font-family: arial;
font-weight: bold;
color:blanchedalmond;
}
form{
margin: 10px;
width: 95%;
padding: 10px;
}
input[type="text"]{
display: flex;
margin-left: 10px;
width: 300px;
height: 30px;
border: 1px solid #ccc;
border-radius: 5px;
border-color: black;
}
.box1{
margin: 5px;
padding: 10px;
}
.box2{
margin: 5px;
padding: 10px;
}
.box3{
margin: 5px;
padding: 10px;
}
.box4{
margin: 5px;
padding: 10px;
}
button{
background-color: blanchedalmond;
margin: 10px;
width: 100px;
height: 40px;
font-size: 16px;
font-weight: bold;
border-radius: 5px;
}
</style>
<title>Financial Manager Dashboard</title>
</head>
<body>
<div class="banner-img"></div>
<div class="container my-5">
<h2>Financial Records</h2>
<form method="post">
<div class="box1">
<label>Project ID</label>
<input type="text" class="form-control" placeholder="Enter the project id" name="projectId" value="<?php echo $projectId; ?>">
</div>
<div class="box2">
<label>Description</label>
<input type="text" class="form-control" placeholder="Enter the description" name="description" value="<?php echo $description; ?>">
</div>
<div class="box3">
<label>Payment</label>
<input type="text" class="form-control" placeholder="Enter the payment" name="payment" value="<?php echo $payment; ?>">
</div>
<div class="box4">
<label>Payment Status</label>
<input type="text" class="form-control" placeholder="Enter the payment status" name="paymentStatus" value="<?php echo $paymentStatus; ?>">
</div>
<!-- Add a hidden input field to pass 'updateinvoiceId' -->
<input type="hidden" name="updateinvoiceId" value="<?php echo $invoiceId; ?>">
<button type="submit" class="btn btn-primary" name="submit">Update</button>
</form>
</div>
</body>
</html>