-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew 1.txt
130 lines (75 loc) · 2.3 KB
/
new 1.txt
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
<?php
if ( isset($_POST['Room']) ) {
$Room = $_POST['Room'];
} else {
$Room = "";
}
function isValidRoom($str, $length) {
$pattern = "/[0-9]{3,}/";
return preg_match($pattern, $str);
}
//filter***********************
function strFilter($str, $param){
$filter = "";
if (strstr($param, "dot")) { $filter .="\.";}
if (strstr($param, "at")) { $filter .="@";}
if (strstr($param, "L")) { $filter .="a-zA-Z";}
if (strstr($param, "N")) { $filter .="0-9";}
if (strstr($param, "U")) { $filter .="U";}
if (strstr($param, "D")) { $filter .="\-";}
if (strstr($param, "S")) { $filter .=" ";}
$pattern = "/[^".$filter."]+/";
return preg_replace($pattern,"",$str);
}
//Process the first of room number//
if (isset($_POST['search_room']) ) {
$Room = strFilter($Room, 'N');
if ($errList != ""){
$errList = "<p><strong>An Error Has Occured!:</strong></p><ul>".$errList."</ul>";
}
if (strlen($Room) < 3) {
$errList .= "<li>You Need to enter a room number</li>";
$error['mail'] = "False 1";
}
if ( (empty($Room)) || (!isValidRoom($Room)) ) {
$errList .= "<li>You Need to enter a Valid Room Number</li>";
$error['2mail'] = "False 2";
}
if(!is_array($error)) {
#######process form########
//start arrays//
$last_name_array = array();
$first_name_array = array();
$WiD_array = array();
//End Arrays
//Connect to Database
include('../access/a/b/unauthorized/establish_link.php');
$query = mysql_query("SELECT * FROM Resident_Rooster WHERE RoomNumber='$roomNumber'");
$numrows = mysql_num_rows($query);
//Start Query
if ($numrows!=0){
$i = 0;
//Counter
while ($row = mysql_fetch_assoc($query)){
$dbroomnumber = $row['RoomNumber'];
if ($roomNumber==$dbroomnumber){
$last_name_array[$i] = $row['LastName'];
$first_name_array[$i] = $row['FirstName'];
$WiD_array[$i] = $row['WiD'];
$i++;
}
}
}
//End Counter
if ($roomNumber==$dbroomnumber){
$resident_last_name = $last_name_array;
$resident_first_name = $first_name_array;
$resident_WiD = $WiD_array;
$resident_roomNumber = $roomNumber;
$counter_value = $counter;
$Processed = "Okay";
}
}
}
//end process post of room number//
?>