-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditExpense.php
77 lines (72 loc) · 2.96 KB
/
editExpense.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
<?php
session_start();
if (!isset($_SESSION['id']) || !isset($_SESSION['role']) || $_SESSION['role'] != 'admin') {
header('Location: login.php');
mysqli_close($conn);
}
include 'connection.php';
include_once('includes/header.php');
?>
<?php
$id = $_REQUEST['id'];
$str = "SELECT * FROM expense WHERE id=$id";
$result = mysqli_query($conn, $str);
$expense = mysqli_fetch_array($result);
?>
<style>
.container-center {
display: flex;
justify-content: center;
align-items: center;
}
</style>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header text-center">Edit Expense</h1>
</div>
</div>
<div class="row">
<div class="container-center">
<div class="col-md-8">
<form method="post" action="">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title text-center " style="font-weight: bold;">Update Information</h3>
</div>
<div class="panel-body">
<div class="form-group">
<label for="">Description</label>
<textarea rows="3" style="height:100%;" type="text" class="form-control" name="description" id="description" placeholder="Enter description"><?php echo $expense['description'] ?></textarea>
</div>
<div class="form-group">
<label for="">Amount</label>
<input type="text" value="<?php echo $expense['amount'] ?>" class="form-control" name="amount" id="">
</div>
<div class="form-group">
<label for="">Note</label>
<textarea rows="2" style="height:100%;" type="text" class="form-control" name="note" id="note" placeholder="Enter Note If needed"><?php echo $expense['note'] ?></textarea>
</div>
<div class="form-group text-center">
<input class="btn btn-primary" type="submit" name="submit" value="Update Expense">
<a class="btn btn-info" href="expense.php">List All Expenses</a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
include_once('includes/footer.php');
if (isset($_POST['submit'])) {
$description = $_POST['description'];
$amount = $_POST['amount'];
$note = $_POST['note'];
$str = "UPDATE expense SET description='" . $description . "', amount='" . $amount . "', note='" . $note . "' WHERE id= $id";
if (mysqli_query($conn, $str)) {
echo "<script> window.location.replace('allExpense.php'); </script>";
}
}
?>