forked from marymuhia/Microfinance-Loan-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddmember.php
More file actions
293 lines (273 loc) · 10.7 KB
/
addmember.php
File metadata and controls
293 lines (273 loc) · 10.7 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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<?php require_once('Connections/mlms.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "../index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO member (memberId, fName, lName, gender, phone, occupation, email, password, address, county, district, location, photo, dob, regDate) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['memberId'], "int"),
GetSQLValueString($_POST['fName'], "text"),
GetSQLValueString($_POST['lName'], "text"),
GetSQLValueString($_POST['Gender'], "text"),
GetSQLValueString($_POST['phone'], "text"),
GetSQLValueString($_POST['occupation'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['county'], "text"),
GetSQLValueString($_POST['district'], "text"),
GetSQLValueString($_POST['location'], "text"),
GetSQLValueString($_POST['photo'], "text"),
GetSQLValueString($_POST['dob'], "date"),
GetSQLValueString($_POST['regDate'], "date"));
mysql_select_db($database_mlms, $mlms);
$Result1 = mysql_query($insertSQL, $mlms) or die(mysql_error());
$insertGoTo = "addmember.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
<link rel="stylesheet" type="text/css" href="Assets/css/body.css">
<link rel="stylesheet" type="text/css" href="Assets/css/sidebar.css">
<link rel="stylesheet" type="text/css" href="Assets/css/dropdown.css" />
<link rel="stylesheet" type="text/css" href="font-awesome-4.7.0/css/font-awesome.min.css" />
</head>
<body><div class="nav">
<div class="header" class="responsive">
<span class="title" style="font-size:18px;">MLMS | Admin!</span>
<center>
<h2>Microfinance Loan Management system</h2>
</center>
</div>
</div>
<div id="mySidebar" class="sidebar" class="responsive">
<a href="javascript:void(0)" class="closebtn" onClick="closeNav()">×</a>
<a href="index.php">Member Login</a>
<a href="admin/adminlogin.php">Admin Login</a>
<a href="User/help.php">Help <b>?</b></a>
</div>
<div id="main">
<button class="openbtn" onClick="openNav()">☰</button> </div>
<center>
<div class="mainn">
<h3 >Register</h3>
<form name="form" method="POST" class="form" action="<?php echo $editFormAction; ?>"> <table>
<tr>
<td>
<label for="memberId"><b>ID No/Passport No: </b></label>
<input type="text" placeholder="Enter Member id" pattern="[0-9]*" name="memberId" maxlength="20"required>
<br/> <br/>
</td>
<td>
<label for="fName"><b>First name: </b></label>
<input type="text" placeholder="Enter First name" pattern="[a-z A-Z]*" name="fName" maxlength="20" required>
<br/> <br/>
</td>
<td>
<label for="lName"><b>Second name: </b></label>
<input type="text" placeholder="Enter second Name" pattern="[a-z A-Z]*" name="lName" maxlength="20"required>
<br/> <br/>
</td>
</tr>
<tr>
<td>
<label for="gender"><b>Gender:</b></label>
<input type="radio" name="Gender" value="M" checked="checked" /><b>Male</b><input type="radio" name="Gender" value="F" maxlength="20" /><b>Female</b>
<br/> <br/>
</td>
<td>
<label for="phone"><b>Phone Number: </b></label>
<input type="text" placeholder="Enter Phone number" name="phone" required maxlength="20"/>
<br/> <br/>
</td>
<td>
<label for="occupation"><b>Occupation:</b></label>
<select name="occupation"maxlength="20"/>
<option value="farmer">Farmer</option>
<option value="teacher">Teacher</option>
<option value="student">Student</option>
<option value="other">Other</option>
</select>
<br/> <br/>
</td></tr>
<tr>
<td>
<label for="email"><b>Email address: </b></label>
<input type="text" placeholder="Enter Email" name="email" required maxlength="20"/>
<br/> <br/>
</td>
<td>
<label for="password"><b>Password: </b></label>
<input type="password" placeholder="Enter Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" name="password" required maxlength="20">
<br/> <br/>
</td>
<td>
<label for="address"><b>Address: </b></label>
<input type="text" placeholder="Enter address" name="address" required maxlength="20" required="required">
<br/> <br/>
</td></tr>
<tr>
<td>
<label for="county"><b>County: </b></label>
<select name="county"maxlength="20"/>
<option value="mombasa">Mombasa</option>
<option value="bungoma">Bungoma</option>
<option value="nyeri">Nyeri</option>
<option value="uasin gishu">Uasin Gishu</option>
<option value="nakuru">Nakuru</option>
<option value="murang'a">Murang'a</option>
<option value="kiambu">Kiambu</option>
</select>
<br/> <br/>
</td>
<td>
<label for="district"><b>District: </b></label>
<select name="district" maxlength="20"/>
<option value="Kangema">Kangema</option>
<option value="kanduyi">Kanduyi</option>
<option value="Mwiki">Mwiki</option>
<option value="naivasha">Naivasha</option>
<option value="nakuru">Mathira</option>
<option value="mathioya">Mathioya</option>
<option value="kesses">Kesses</option>
</select> <br/> <br/>
</td>
<td>
<label for="location"><b>Location: </b></label>
<select name="location" maxlength="20"/>
<option value="githi">Githi</option>
<option value="kibabii">Kibabii</option>
<option value="butieli">Butieli</option>
<option value="konyu">Konyu</option>
<option value="free area">Free area</option>
<option value="zimmerman">Zimmerman</option>
<option value="kirigiti">Kirigiti</option>
</select>
<br/> <br/>
</td>
</tr>
<tr>
<td>
<label for="dob"><b>Date of birth: </b></label>
<input type="date" name="dob" required maxlength="20" required="required">
<br/> <br/>
</td>
<td>
<label for="photo"><b>Upload photo: </b></label>
<input type="file" name="photo" value="" size="32" required="required">
<br/> <br/>
</td>
<td>
<label for="regDate"><b>Registration date: </b></label>
<input type="date" name="regDate" min="2019-05-18" required maxlength="20"/>
<br/> <br/>
</td>
</tr>
<tr>
<td>
<button type="submit" class="registerbtn">Register</button>
</td>
<td>
<button type="reset" class="registerbtn">Reset</button>
</td>
<td> <a href="index.php">Sign in</a></td>
</tr>
<input type="hidden" name="MM_insert" value="form" />
</form>
</table>
</div>
</center>
<script>
function openNav() {
document.getElementById("mySidebar").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidebar").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
}
</script>
<script>
/* Loop through all dropdown buttons to toggle between hiding and showing its dropdown content - This allows the user to have multiple dropdowns without any conflict */
var dropdown = document.getElementsByClassName("dropdown-btn");
var i;
for (i = 0; i < dropdown.length; i++) {
dropdown[i].addEventListener("click", function() {
this.classList.toggle("active");
var dropdownContent = this.nextElementSibling;
if (dropdownContent.style.display === "block") {
dropdownContent.style.display = "none";
} else {
dropdownContent.style.display = "block";
}
});
}
</script>
<div class="footer" align="center">
© COPYRIGHT <?php echo date("Y"); ?>. All Rights Reserved
</div>
</body>
</html>