-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_income.php
More file actions
123 lines (114 loc) · 3.01 KB
/
add_income.php
File metadata and controls
123 lines (114 loc) · 3.01 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
<?php
include 'db.php';
// Check if session is not already started
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$amount = $_POST['amount'];
$source = $_POST['source'];
$user_id = $_SESSION['user_id'];
$sql = "INSERT INTO income (user_id, amount, source, date) VALUES ('$user_id', '$amount', '$source', NOW())";
if ($conn->query($sql) === TRUE) {
$message = "Income added successfully!";
} else {
$message = "Error: " . $conn->error;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Income</title>
<style>
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(to right, royalblue, skyblue);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
color: white;
}
.form-container {
background: rgba(255, 255, 255, 0.9);
padding: 30px;
border-radius: 12px;
text-align: center;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
width: 400px;
}
h2 {
color: slateblue;
margin-bottom: 20px;
}
label {
font-size: 16px;
font-weight: bold;
color: slateblue;
}
input {
width: 90%;
padding: 8px;
margin-top: 5px;
border: 1px solid #1E90FF;
border-radius: 5px;
outline: none;
}
.button {
background: #1E90FF;
color: white;
text-decoration: none;
padding: 10px;
border-radius: 5px;
font-weight: bold;
transition: background 0.3s ease-in-out;
border: none;
cursor: pointer;
width: 100%;
margin-top: 10px;
}
.button:hover {
background: #007BFF;
}
.back-button {
background: #333;
color: white;
text-decoration: none;
padding: 10px;
border-radius: 5px;
font-weight: bold;
border: none;
cursor: pointer;
width: 30%;
margin-top: 0px;
display: inline-block;
text-align: center;
}
.back-button:hover {
background: #222;
}
</style>
</head>
<body>
<div class="form-container">
<h2>📥 Add Income</h2>
<form method="post">
<label>Amount:</label>
<input type="number" name="amount" required><br><br>
<label>Source:</label>
<input type="text" name="source" required><br><br>
<button type="submit" class="button">➕ Add Income</button>
</form>
<br>
<a href="index.php" class="button back-button">Back to Home</a>
</div>
</body>
</html>