-
Notifications
You must be signed in to change notification settings - Fork 0
/
addacc.php
214 lines (167 loc) · 4.68 KB
/
addacc.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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
/**
* Make sure you started your'e sessions!
* You need to include su.inc.php to make SimpleUsers Work
* After that, create an instance of SimpleUsers and your'e all set!
*/
session_start();
require_once(dirname(__FILE__)."/simpleusers/su.inc.php");
$SimpleUsers = new SimpleUsers();
$userId=0;
$user = $SimpleUsers->getSingleUser($userId);
// This is a simple way of validating if a user is logged in or not.
// If the user is logged in, the value is (bool)true - otherwise (bool)false.
if( !$SimpleUsers->logged_in )
{
header("Location: login.php");
exit;
}
// If the user is logged in, we can safely proceed.
$users = $SimpleUsers->getUsers();
include 'header.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
* { margin: 0px; padding: 0px; }
body
{
padding: 30px;
font-family: Calibri, Verdana, "Sans Serif";
font-size: 12px;
}
table
{
width: 800px;
margin: 0px auto;
}
th, td
{
padding: 3px;
}
.right
{
text-align: right;
}
h1
{
color: #FF0000;
border-bottom: 2px solid #000000;
margin-bottom: 15px;
}
p { margin: 10px 0px; }
p.faded { color: #A0A0A0; }
.center {
margin: auto;
width: 60%;
border: 3px solid #73AD21;
padding: 10px;
text-align: center;
font-size: 30px;
}
input[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1>ADD Bank Account No</h1>
<body>
<a href="index.php">Home</a>
<br/><br/>
<div class="center">
<form action="addacc.php" method="post" name="form1">
<table width="25%" border="0">
<tr>
<td>Account Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Account No</td>
<td><input type="text" name="company"></td>
</tr>
<tr>
<td>Current Balance</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td>Branch</td>
<td><input type="text" name="mobile"></td>
</tr>
<tr>
<td>Note</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td><input type="hidden" name="addby" value="<?php echo $user["uUsername"]; ?>"></td>
<td><input type="submit" name="Submit" value="Add"></td>
</tr>
</table>
</form></div>
<br /><br />
<?php
if(isset($_POST['Submit'])) {
$name = mysqli_real_escape_string($mysqli, $_POST['name']);
$company = mysqli_real_escape_string($mysqli, $_POST['company']);
$address = mysqli_real_escape_string($mysqli, $_POST['address']);
$mobile = mysqli_real_escape_string($mysqli, $_POST['mobile']);
$email = mysqli_real_escape_string($mysqli, $_POST['email']);
$addby = mysqli_real_escape_string($mysqli, $_POST['addby']);
if(empty($name) || empty($company) || empty($address) || empty($mobile) ) {
if(empty($name)) {
echo "<font color='red'>Acc name field is empty.</font><br/>";
}
if(empty($company)) {
echo "<font color='red'>Account No field is empty.</font><br/>";
}
if(empty($address)) {
echo "<font color='red'>Balance field is empty.</font><br/>";
}
if(empty($mobile)) {
echo "<font color='red'>Branch field is empty.</font><br/>";
}
//link to the previous page
echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
} else {
//insert data to database
$result = mysqli_query($mysqli, "INSERT INTO bankacc(accname,accno,balance,branch,bnote,addby) VALUES('$name','$company','$address','$mobile','$email','$addby')");
$lastb = mysqli_query($mysqli, "SELECT bid FROM bankacc ORDER BY bid DESC LIMIT 1");
$ree = mysqli_fetch_array($lastb);
$bid = $ree['bid'];
$date = date("Y-m-d");
$details = "Account Opening";
$with = 0;
$depo =0;
$tnote = "Account Added";
$resu = mysqli_query($mysqli, "INSERT INTO trans(date,bid,details,withdraw,deposit,cbalance,tnote,addby) VALUES('$date','$bid','$details','$with','$depo','$address','$tnote','$addby')");
//display success message
echo "<font color='green'>Account added successfully.";
echo "<br/><a href='listacc.php'>View Result</a>";
}
}
?>
</body>
</html>
<?php include 'footer.php'; ?>